I am new to React and Material UI. What I am trying to do, is to create a simple permissions dialog (like usually we see on mobiles asking for privacy or location permissions, or like in Chrome on desktop)), which appears a few seconds after the home page is loaded. So that the user first sees the home page and then after about 2 seconds appears the permission dialog (as light box).
I've checked already the alert dialog example in the Material Ui docs which is great. What I am straggling with is how to:
- Display the dialog after a certain delay (let's say 2 seconds)
- Display it only once. Meaning that first time you enter the home page it is displayed, and that's it. Browsing through other site's pages would not show it again. (similar to chrome behaviour)
I would like to be able to do something like this:
(AlertDialog code by Material UI)
export default function Home() {
return (
<Container maxWidth="sm">
<Box component="img" src="/logo.svg" pt="58px" />
<Typography component="div" gutterBottom>
Home page
</Typography>
<AlertDialog wait="2000" />
</Container>
);
}