Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Timer component for use as a Suspense fallback
function Timer() {
const startTime = React.useRef(;
const [time, setTime] = React.useState(;
React.useEffect(() => {
const id = setTimeout(() => {
ReactDOM.flushSync(() => {
}, 2);
return () => clearTimeout(id);
return (
<div className="Fallback">
<h3>🌀 App Level Suspense</h3>
<b>{Math.round(time - startTime.current)} ms</b>

This comment has been minimized.

Copy link
Owner Author

sw-yx commented Nov 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.