web2019/static/js/shop/options/Notification.jsx

30 lines
837 B
React
Raw Normal View History

import {OverlayTrigger, Tooltip} from "react-bootstrap";
import React, {useEffect, useState} from "react";
export function Notification({id, tip, content, sideMenuIsOpen}) {
const [show, setShow] = useState(false);
useEffect(() => {
setTimeout(() => {
setShow(true)
}, 100);
setTimeout(() => {
setShow(false)
}, 5000);
}, []);
2024-01-05 13:15:43 +08:00
return (
<OverlayTrigger
placement="top"
trigger={["click", "hover"]}
2024-01-05 13:15:43 +08:00
style={{display: 'inline'}}
show={show}
onToggle={() => setShow(false)}
overlay={props => <Tooltip id={id} {...props}>{tip}</Tooltip>}
rootClose={!sideMenuIsOpen}
>
{content}
</OverlayTrigger>
)
}