You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The instability in useId() across suspense appears to me to be a symptom of a larger problem. The larger problem is this Suspense Caveat "React does not preserve any state for renders that got suspended before they were able to mount for the first time. When the component has loaded, React will retry rendering the suspended tree from scratch."
While I am sure there are good reasons not to preserve state for renders, I believe preserving it would unlock many powerful optimizations/coding patterns, such as those listed in this RFC. I would personally want to use preserving state between suspensions to simplify loading data with use and the React Compiler. When I look at the compiler output for this example it looks like the code should work but it will cause an infinite loop.
Update:
I just remembered that React is experimenting with keeping state across renderers, which is usually lost with the experimental optimisticKey.
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
View formatted RFC.