Spaces:
Sleeping
Sleeping
| import React, { useEffect } from 'react'; | |
| import { FaCheckCircle, FaTimesCircle } from 'react-icons/fa'; | |
| import './Toast.css'; | |
| const Toast = ({ message, type = 'success', onClose }) => { | |
| useEffect(() => { | |
| const timer = setTimeout(() => { | |
| onClose(); | |
| }, 3000); | |
| return () => clearTimeout(timer); | |
| }, [onClose]); | |
| return ( | |
| <div className={`toast ${type}`}> | |
| {type === 'success' ? <FaCheckCircle /> : <FaTimesCircle />} | |
| {message} | |
| </div> | |
| ); | |
| }; | |
| export default Toast; |