Created
May 27, 2020 16:33
-
-
Save r3dm1ke/4ec0e9086085fe66c9ad15a1a679c1cc 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
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