2023-02-22 20:21:00 +03:00
|
|
|
import React, { useState, FC, ReactElement } from 'react';
|
2021-02-04 10:24:12 +03:00
|
|
|
|
|
|
|
export const AlertMessageContext = React.createContext({
|
2021-02-04 19:04:00 +03:00
|
|
|
message: null,
|
2021-02-07 06:38:58 +03:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
setMessage: (text?: string) => null,
|
2021-02-04 10:24:12 +03:00
|
|
|
});
|
|
|
|
|
2023-02-22 20:21:00 +03:00
|
|
|
export type AlertMessageProviderProps = {
|
|
|
|
children: ReactElement;
|
|
|
|
};
|
|
|
|
|
|
|
|
const AlertMessageProvider: FC<AlertMessageProviderProps> = ({ children }) => {
|
2021-02-04 19:04:00 +03:00
|
|
|
const [message, setMessage] = useState('');
|
|
|
|
|
|
|
|
const providerValue = {
|
|
|
|
message,
|
|
|
|
setMessage,
|
|
|
|
};
|
|
|
|
return (
|
|
|
|
<AlertMessageContext.Provider value={providerValue}>{children}</AlertMessageContext.Provider>
|
|
|
|
);
|
|
|
|
};
|
2021-02-04 10:24:12 +03:00
|
|
|
|
2021-02-04 19:04:00 +03:00
|
|
|
export default AlertMessageProvider;
|