Major Changes
-
#2939
360e85462
Thanks @Andarist! - This package now accepts React 18 as a peer dep and the implementation has been rewritten to useuse-sync-external-store
package. This doesn't break compatibility with older versions of React since we are using the shim to keep compatibility with those older versions. -
#2939
360e85462
Thanks @Andarist! -asEffect
andasLayoutEffect
action creators were removed. They were not fitting the React model that well and could lead to issues as their existence suggested that they are easy to use.To execute actions at those exact times you can always either just call your stuff directly from those effects or send events to the machine from those effects and execute explicit actions in response to said events.
-
#2939
360e85462
Thanks @Andarist! - The signatures ofuseMachine
anduseService
integrating with@xstate/fsm
were changed. They now only accept a single generic each (TMachine
andTService
respectively). This has been done to match their signatures with the related hooks that integrate withxstate
itself.
Patch Changes
-
#2939
360e85462
Thanks @Andarist! - In v2 we have changed signatures ofuseMachine
anduseInterpret
. Instead of accepting a list of generics they now only support a single generic:TMachine
. This change, erroneously, was only introduced to types targeting TS@4.x but the types targeting previous TS releases were still using the older signatures. This has now been fixed and users of older TS versions should now be able to leverage typegen with@xstate/react
. -
#2939
360e85462
Thanks @Andarist! -useMachine
forxstate
now correctly rerenders with the initial state when the internal service is being restarted. This might happen during Fast Refresh and now you shouldn't be able to observe this stale state that didn't match the actual state of the service. -
#2939
360e85462
Thanks @Andarist! -useMachine
for@xstate/fsm
now starts the service in an effect. This avoids side-effects in render and improves the compatibility withStrictMode
. -
#2939
360e85462
Thanks @Andarist! - Implementations given touseMachine
targeting@xstate/fsm
are now updated in a layout effect. This avoid some stale closure problems for actions that are executed in response to events sent from layout effects. -
Updated dependencies [
360e85462
,360e85462
]:- @xstate/fsm@2.0.0