2021-02-04 19:04:00 +03:00
|
|
|
import React, { useState } from 'react';
|
2021-02-04 10:24:12 +03:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
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
|
|
|
});
|
|
|
|
|
|
|
|
const AlertMessageProvider = ({ 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
|
|
|
|
|
|
|
AlertMessageProvider.propTypes = {
|
2021-02-04 19:04:00 +03:00
|
|
|
children: PropTypes.element.isRequired,
|
2021-02-04 10:24:12 +03:00
|
|
|
};
|
|
|
|
|
2021-02-04 19:04:00 +03:00
|
|
|
export default AlertMessageProvider;
|