owncast/web/utils/alert-message-context.tsx

28 lines
606 B
TypeScript

import React, { useState } 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;