[Feature] @xstate/react: support React's transition API #5073
-
React's useTransition hook and startTransition method allow's a state change to be declared as a Here's a minimalistic example that I forked from https://github.com/InterBolt/tearable-dots and included a battery test for @xstate/react and also battery test for a custom implementation of the hooks but supporting transitions. At the moment |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
It's not possible to support today what you are asking for because our hooks also return a reference to This alone means that we can't migrate this hook to Similarly, |
Beta Was this translation helpful? Give feedback.
The problem can be surfaced by consuming the
actorRef
elsewhere. Tearing can happen when you consume the same external data source in multiple places when each is coordinated outside of React. That's why I'm saying that returningactorRef
makes it impossible~ to avoid tearing. Since we return it, we allow other consumers that won't sync through the returned snapshot (and thus through React's own scheduling). Any other piece of code is free to use that returnedactorRef
, subscribe to it and thus introduce tearing.