Generateurv2/frontend/context/alert.context.js
2022-05-18 10:15:54 +02:00

23 lines
494 B
JavaScript

import { createContext, useContext } from "react"
const alerContextDefaultValue = {
alert: ()=>{},
}
const alertContext = createContext(alerContextDefaultValue)
export const AlertType = {
Success: "Success",
Error: "Error",
Info: "Info",
Warning: "Warning",
};
export function useAlert() {
return useContext(alertContext)
}
export function AlertProvider({ children, setAlert }) {
return <alertContext.Provider value={{alert: setAlert}}>{children}</alertContext.Provider>
}