-
Notifications
You must be signed in to change notification settings - Fork 46.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React 18 : Possible Transition use case? Rendering large table with filtered tabs #21696
Comments
Playing around more I landed on this solution: https://codesandbox.io/s/usetransition-tab-test-forked-mjvvz?file=/src/App.js This seems to cover my use case. I'd be curious to hear if you this is how you would approach this problem with this API, but feel free to close this issue, as it seems I might have figured it out on my own. edit: I found some tweets from Dan that go over this use case 😄 .... Well at least I learned something lol. Awesome stuff, looking forward to using it more! |
So there's multiple ways to approach this depending on what UX you want. The canonical case where you'd use If you want to show the new screen ASAP but show some kind of a spinner while it's rendering, we have a different feature for this that isn't documented: #19936. Here is an example: https://codesandbox.io/s/usetransition-tab-test-forked-4b3zx?file=/src/App.js. Specifically, presence of the Hope this is useful. |
Thanks for the additional info, I really appreciate it! I was curious if there was a "delay" or "load time" prop for that specific use case, because that starts getting into functionality that is very hard (not even sure if possible) to replicate in user code. Looking through the codebase, it seems that, at least at some point, the The suspense example with the key manipulation is pretty neat—looking forward to seeing the final iteration of these features. Thanks again, Dan! |
Apologies if this is an inappropriate place to ask this type of question. When reading about React 18, in particular the startTransition API, I started thinking of problems I've run into in the past where I had to do lots of manual management of renders to provide good UX. I tried to recreate the original problem (at least a contrived version of it) in a CodeSandbox:
https://codesandbox.io/s/usetransition-tab-test-575cu?file=/src/App.js
I attempted to describe the problem in the sandbox, but basically I am trying to optimize the interaction and navigation of the Tab components onClick—the "high priority" update—and defer the rendering of the table data (through a loading spinner or delay of table data rendering).
Reading through the startTransition explanation, I'm not sure if this an appropriate use case. My tab component is not a native browser component, and it seems that I only have the ability to mark "low-priority" updates and not the opposite (eg. wrapping handleClick as a high-priority update).
I was hoping to get some clarification if my mental model is off here. I am aware there are other ways to deal with this problem (eg. list virtualization), but I'm mostly trying to understand the scope of the startTransition API.
Thanks for all the hard work! I'm very excited about the new developments in React 18 and appreciate your team's commitment to pragmatism.
The text was updated successfully, but these errors were encountered: