import React, {useState, useEffect} from 'react' const Popup = ({popup}) => { const [visible, setVisible] = useState(false) const { content = null, time = null, error = null, yes = null, no = null, } = popup useEffect(() => { setVisible(true) time && setTimeout(() => setVisible(false), time) }, [popup]) if (!content) return null return visible ? (
{ content }
{ (yes || no) && (
{[yes, no].map(a => a && { setVisible(false); a.action() }} value={a.label} />)}
) }
) : null } export default Popup