Created
January 26, 2023 19:43
-
-
Save chrisoverstreet/79e2ccd7e89ef29dd7b1def2dd74b575 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { CustomNextPage } from '../_app'; | |
import { Stack, Typography } from '@mui/material'; | |
import { EventProvider, useEvent, useEventGuests } from '@events'; | |
import { useEffect, useState } from 'react'; | |
export const TestPage: CustomNextPage = () => { | |
const [show, setShow] = useState(false); | |
useEffect(() => { | |
const timeoutId = setTimeout(() => setShow((prev) => !prev), 1000); | |
return () => clearTimeout(timeoutId); | |
}, [show]); | |
const { event, fetching: eventFetching } = useEvent(); | |
const { guests, fetching: guestsFetching } = useEventGuests(); | |
return ( | |
<Stack direction='row'> | |
{show && <ChildComponent />} | |
<Stack direction='column' sx={{ width: '50%', overflow: 'hidden' }}> | |
<Typography>Event fetching: {eventFetching.toString()}</Typography> | |
{event && ( | |
<Typography> | |
<pre>{JSON.stringify(event, null, `\t`)}</pre> | |
</Typography> | |
)} | |
</Stack> | |
<Stack direction='column' sx={{ width: '50%', overflow: 'hidden' }}> | |
<Typography>Guests fetching: {guestsFetching.toString()}</Typography> | |
{guests && ( | |
<Typography> | |
<pre>{JSON.stringify(guests, null, `\t`)}</pre> | |
</Typography> | |
)} | |
</Stack> | |
</Stack> | |
); | |
}; | |
const ChildComponent = () => { | |
const { refetchGuests } = useEventGuests(); | |
return null; | |
}; | |
export default () => ( | |
<EventProvider> | |
<TestPage /> | |
</EventProvider> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment