I've written the following hook for alert boxes:
import MuiAlert from '@material-ui/lab/Alert';
import { Snackbar } from '@material-ui/core';
import React from 'react';
export const useAlert = () => {
    const [open, setOpen] = React.useState(false);
    const [message, setMessage] = React.useState('');
    const openAlert = (message) => {
        setOpen(true);
        setMessage(message);
    };
    const closeAlert = (event, reason) => {    
        setOpen(false);
    };
    return {
        openAlert,
        Alert: <Snackbar open={open} onClose={closeAlert}><MuiAlert onClose={closeAlert}>{ message }</MuiAlert></Snackbar>
    };
};
and I integrate this hook into other functional components as so:
import { useAlert } from './useAlert';
const Dashboard = () => {
    const { openAlert, Alert } = useAlert();
    return (
        <div>{ Alert }</div>
    )
};
I know that it's bad practice to return functional components from React hooks since the hook will produce a new instance of the component on every render.
However, here, I'm returning a JSX element and not a component. Is this still bad practice?
 
    