Skip to content

Commit 9bec659

Browse files
acdlitefacebook-github-bot
authored andcommitted
Implement experimental_useOptimisticState (#26740)
Summary: 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. DiffTrain build for commit facebook/react@491aec5. Changelog: [Internal] << DO NOT EDIT BELOW THIS LINE >> Reviewed By: sammy-SC Differential Revision: D45448404 Pulled By: tyao1 fbshipit-source-id: 09b1e8c77fb6fb5d9f0859a2392234371c011b4f
1 parent b46a7e7 commit 9bec659

File tree

1 file changed

+1
-1
lines changed
  • packages/react-native/Libraries/Renderer

1 file changed

+1
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9545e4810c2dc8922f575b6d8f726503a7345d0c
1+
491aec5d6113ce5bae7c10966bc38a4a8fc091a8

0 commit comments

Comments
 (0)