mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
Implement experimental_useOptimisticState (#26740)
This adds an experimental hook tentatively called useOptimisticState. (The actual name needs some bikeshedding.) The headline feature is that you can use it to implement optimistic updates. If you set some optimistic state during a transition/action, the state will be automatically reverted once the transition completes. Another feature is that the optimistic updates will be continually rebased on top of the latest state. It's easiest to explain with examples; we'll publish documentation as the API gets closer to stabilizing. See tests for now. Technically the use cases for this hook are broader than just optimistic updates; you could use it implement any sort of "pending" state, such as the ones exposed by useTransition and useFormStatus. But we expect people will most often reach for this hook to implement the optimistic update pattern; simpler cases are covered by those other hooks.
This commit is contained in:
@@ -463,5 +463,6 @@
|
||||
"475": "Internal React Error: suspendedState null when it was expected to exists. Please report this as a React bug.",
|
||||
"476": "Expected the form instance to be a HostComponent. This is a bug in React.",
|
||||
"477": "React Internal Error: processHintChunk is not implemented for Native-Relay. The fact that this method was called means there is a bug in React.",
|
||||
"478": "Thenable should have already resolved. This is a bug in React."
|
||||
"478": "Thenable should have already resolved. This is a bug in React.",
|
||||
"479": "Cannot update optimistic state while rendering."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user