Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Savy011/fullstackopen-exercises. My Exercise Submissions for FullStack Open fullstackopen.com/en
Something went wrong. Try again.
595 B · 26 lines
JavaScript
at main
1234567891011121314151617181920212223242526import { useReducer, createContext, useContext } from 'react'
const notifReducer = (state, action) => { switch(action.type) { case 'SET': return action.payload case 'CLEAR': return '' default: return state }}
export const NotifContext = createContext()
export const NotifContextProvider = (props) => { const [ notif, notifDispatch] = useReducer(notifReducer, '')
return ( <NotifContext.Provider value={[notif, notifDispatch] }> {props.children} </NotifContext.Provider> )}
export default NotifContext