In the docs: https://beta.reactjs.org/reference/react/useTransition#preventing-unwanted-loading-indicators
There's an example of a tab component that only shows up when it has finished loading all its data. Before it's finished, we still see the previously selected tab.
Something quirky is happening here, the TabButtons
are aware of the new tab
state and change their appearance, but in the rest of the JSX it seems we still work with the old value of tab
- because we still see the previously selected tab, instead of no tab at all, or a spinner.
It seems that the tab
state can have two values at the same time, in the same JSX statement.
See here, this is the code from the docs with a few things added to help in debugging: https://codesandbox.io/s/how-does-usetransition-work-n2vc9x?file=/App.js