Minor Changes
-
81dd3dd:
useActorRef,useActoranduseMachineaccept an already-created actor, such as one fromrestoreActor. Thesnapshotoption is removed; restore the actor withrestoreActorfromxstate/persistand pass it to the hook. The hook starts the actor on mount and stops it on unmount, as it does for actors it creates. Create the actor once per component instance.import { useActor } from '@xstate/react'; import { restoreActor } from 'xstate/persist'; function App({ persisted }) { const [actor] = useState(() => restoreActor(machine, persisted)); const [snapshot, send] = useActor(actor); // ... }
createActorContext(...).Provideraccepts the same actor through itsactorprop:<SomeContext.Provider actor={actor}>{children}</SomeContext.Provider>
Patch Changes
- 6cf6982: XState v6 enters beta. No further breaking changes are planned for APIs tagged
@public; any that are needed will be called out with a migration path. APIs tagged@experimentalmay still change.