Skip to content

Instantly share code, notes, and snippets.

@r3dm1ke
Created May 27, 2020 16:33
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 r3dm1ke/4ec0e9086085fe66c9ad15a1a679c1cc to your computer and use it in GitHub Desktop.
Save r3dm1ke/4ec0e9086085fe66c9ad15a1a679c1cc to your computer and use it in GitHub Desktop.
const App = () => {
const [resource, setResource] = useState(initialResource);
const [startTransition, isPending] = useTransition({timeoutMs: 1000});
return (
<>
<button
disabled={isPending}
onClick={() => {
startTransition(() => {
setResource(carResource);
});
}}
>Load cars</button>
{isPending ? "Loading..." : null}
<CarView resource={resource}/>
</>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment