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,
|
2023-05-21 07:15:25 +03:00
|
|
|
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;
|