Modal.jsx 606 B

123456789101112131415161718192021
  1. import Alert from '@mui/material/Alert';
  2. import { useSelector, useDispatch } from 'react-redux';
  3. import { deleteResponseMessage } from '../../reducers/userDataReducer';
  4. export const Modal = () => {
  5. let text = useSelector(state=> state.userDataReducer.responseMessage)
  6. const dispatch =useDispatch();
  7. if (text){
  8. setTimeout(() => {
  9. dispatch(deleteResponseMessage())
  10. }, 2500)
  11. }
  12. return <Alert
  13. severity="error"
  14. sx={{display: (text ? 'block':'none' )}}>
  15. {text}
  16. </Alert>
  17. };