Skip to content

Instantly share code, notes, and snippets.

@chrisoverstreet
Created January 26, 2023 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisoverstreet/79e2ccd7e89ef29dd7b1def2dd74b575 to your computer and use it in GitHub Desktop.
Save chrisoverstreet/79e2ccd7e89ef29dd7b1def2dd74b575 to your computer and use it in GitHub Desktop.
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