owncast/web/utils/alert-message-context.tsx
Dhanu Saputra 0a653aaba7
Remove usage of the PropTypes dependency (#2723)
* Remove usage of the PropTypes dependency

* Prettified Code!

---------

Co-authored-by: dhanusaputra <dhanusaputra@users.noreply.github.com>
2023-02-22 09:21:00 -08:00

26 lines
656 B
TypeScript

import React, { useState, FC, ReactElement } from 'react';
export const AlertMessageContext = React.createContext({
message: null,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
setMessage: (text?: string) => null,
});
export type AlertMessageProviderProps = {
children: ReactElement;
};
const AlertMessageProvider: FC<AlertMessageProviderProps> = ({ children }) => {
const [message, setMessage] = useState('');
const providerValue = {
message,
setMessage,
};
return (
<AlertMessageContext.Provider value={providerValue}>{children}</AlertMessageContext.Provider>
);
};
export default AlertMessageProvider;