Add alert message for global notifications

This commit is contained in:
Gabe Kangas
2021-02-03 23:24:12 -08:00
parent e142fa9e7c
commit e8c24fd2d4
6 changed files with 73 additions and 14 deletions

View File

@@ -0,0 +1,27 @@
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
export const AlertMessageContext = React.createContext({
message: null,
setMessage: (text?: string) => {
return text;
}
});
const AlertMessageProvider = ({ children }) => {
const [message, setMessage] = useState('');
const providerValue = {
message,
setMessage
}
return (
<AlertMessageContext.Provider value={providerValue}>{children}</AlertMessageContext.Provider>
)
}
AlertMessageProvider.propTypes = {
children: PropTypes.element.isRequired
};
export default AlertMessageProvider;