Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
56 lines
1.2 KiB
JavaScript
56 lines
1.2 KiB
JavaScript
import * as React from 'react';
|
|
import Box from '@mui/material/Box';
|
|
import NoSsr from '@mui/material/NoSsr';
|
|
|
|
function LargeTree() {
|
|
return Array.from(new Array(5000)).map((_, index) => <span key={index}>.</span>);
|
|
}
|
|
|
|
export default function FrameDeferring() {
|
|
const [state, setState] = React.useState({
|
|
open: false,
|
|
defer: false,
|
|
});
|
|
|
|
return (
|
|
<div>
|
|
<button
|
|
type="button"
|
|
onClick={() =>
|
|
setState({
|
|
open: !state.open,
|
|
defer: false,
|
|
})
|
|
}
|
|
>
|
|
{'Render NoSsr defer="false"'}
|
|
</button>
|
|
<br />
|
|
<button
|
|
type="button"
|
|
onClick={() =>
|
|
setState({
|
|
open: !state.open,
|
|
defer: true,
|
|
})
|
|
}
|
|
>
|
|
{'Render NoSsr defer="true"'}
|
|
</button>
|
|
<br />
|
|
<br />
|
|
<Box sx={{ width: 300, display: 'flex', flexWrap: 'wrap' }}>
|
|
{state.open ? (
|
|
<React.Fragment>
|
|
<div>Outside NoSsr</div>
|
|
<NoSsr defer={state.defer}>
|
|
.....Inside NoSsr
|
|
<LargeTree />
|
|
</NoSsr>
|
|
</React.Fragment>
|
|
) : null}
|
|
</Box>
|
|
</div>
|
|
);
|
|
}
|