2021-02-04 17:04:00 +01:00
|
|
|
import React, { useState } from 'react';
|
2021-02-04 08:24:12 +01:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
export const AlertMessageContext = React.createContext({
|
2021-02-04 17:04:00 +01:00
|
|
|
message: null,
|
2021-02-07 04:38:58 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
setMessage: (text?: string) => null,
|
2021-02-04 08:24:12 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
const AlertMessageProvider = ({ children }) => {
|
2021-02-04 17:04:00 +01:00
|
|
|
const [message, setMessage] = useState('');
|
|
|
|
|
|
|
|
const providerValue = {
|
|
|
|
message,
|
|
|
|
setMessage,
|
|
|
|
};
|
|
|
|
return (
|
|
|
|
<AlertMessageContext.Provider value={providerValue}>{children}</AlertMessageContext.Provider>
|
|
|
|
);
|
|
|
|
};
|
2021-02-04 08:24:12 +01:00
|
|
|
|
|
|
|
AlertMessageProvider.propTypes = {
|
2021-02-04 17:04:00 +01:00
|
|
|
children: PropTypes.element.isRequired,
|
2021-02-04 08:24:12 +01:00
|
|
|
};
|
|
|
|
|
2021-02-04 17:04:00 +01:00
|
|
|
export default AlertMessageProvider;
|