useTransition
Returns a stateful value for the pending state of the transition, and a function to start it.
startTransition lets you mark updates in the provided callback as transitions.
Can cause content flashes if the completion is too fast - like on this page!
On this page, when you click the button, text appears saying 'Loading...'
However, because the page loads so quickly, this just appears as a quick flash below the button
As a result, useTransition is best used:
- When you know that the content rendering is guaranteed to take a long time
- When you can set a delay on the conetnt rendering
- When you can only display it if rendering time is longer than a certain amount
const [isPending, startTransition] = useTransition();