owncast/web/utils/alert-message-context.tsx
nebunez a123967645 move components folder and fix build errors (#18)
* move components folder and fix build errors

Fixes https://github.com/owncast/owncast/issues/689

* Prettified Code!

Co-authored-by: nebunez <nebunez@users.noreply.github.com>
2021-02-06 19:38:58 -08:00

26 lines
652 B
TypeScript

import React, { useState } from 'react';
import PropTypes from 'prop-types';
export const AlertMessageContext = React.createContext({
message: null,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
setMessage: (text?: string) => null,
});
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;