- Updated dependencies [
8c4b70652acaef2702f32435362e4755679a516d
]:
- Updated dependencies [
25963966c394fc904dc9b701a420b6e204ebe7f7
]:
-
#5055
ad38c35c37
Thanks @SandroMaglione! - Updated types ofuseActor
,useMachine
, anduseActorRef
to requireinput
when defined insidetypes/input
.Previously even when
input
was defined insidetypes
,useActor
,useMachine
, anduseActorRef
would not make the input required:const machine = setup({ types: { input: {} as { value: number } } }).createMachine({}); function App() { // Event if `input` is not defined, `useMachine` works at compile time, but risks crashing at runtime const _ = useMachine(machine); return <></>; }
With this change the above code will show a type error, since
input
is now required:const machine = setup({ types: { input: {} as { value: number } } }).createMachine({}); function App() { const _ = useMachine(machine, { input: { value: 1 } // Now input is required at compile time! }); return <></>; }
This avoids runtime errors when forgetting to pass
input
when defined insidetypes
.
-
#4844
5aa6eb05c
Thanks @davidkpiano! - TheuseSelector(…)
hook from@xstate/react
is now compatible with stores from@xstate/store
.import { createStore } from '@xstate/store'; import { useSelector } from '@xstate/react'; const store = createStore( { count: 0 }, { inc: { count: (context) => context.count + 1 } } ); function Counter() { // Note that this `useSelector` is from `@xstate/react`, // not `@xstate/store/react` const count = useSelector(store, (state) => state.context.count); return ( <div> <button onClick={() => store.send({ type: 'inc' })}>{count}</button> </div> ); }
- #4600
1f2ccb97c
Thanks @davidkpiano! - Typegen-based types for detecting missing implementations have been removed internally.
- #4591
f8cc116d3
Thanks @davidkpiano! - MarkeduseMachine
as aliased, not deprecated.
-
#4507
9ea542c34
Thanks @Andarist! - TheuseMachine(machine)
hook now returns{ snapshot, send, actorRef }
instead of{ state, send, service }
:const { - state, + snapshot, send, - service + actorRef } = useMachine(machine);
-
#4265
1153b3f9a
Thanks @davidkpiano! - FSM-related functions have been removed.
- #3727
5fb3c683d
Thanks @Andarist! -exports
field has been added to thepackage.json
manifest. It limits what files can be imported from a package - it's no longer possible to import from files that are not considered to be a part of the public API. - #4507
9ea542c34
Thanks @Andarist! - TheuseActorRef(logic)
anduseActor(logic)
hooks have been added.
- #3603
44719c294
Thanks @mittinatten! - Improve performance of theuseSelector
by avoidingget
-
#3254
c0b787d2a
Thanks @Andarist! - The major version of this package had to be bumped to allow integrating with the typegen. This package will now require TS version 4.0 or greater.When using hooks from
@xstate/svelte
it's recommended to skip providing explicit generics to them. Note that that generics list has changed since v1 and we now only accept a single generic,TMachine
.
-
#3172
390a115cd
Thanks @Andarist! - Fixed an issue with the internal interpreter created byuseMachine
being unsubscribed when its subscribers' count went to zero. The lifetime of this interpreter should be bound to the lifetime of the component that has created it. -
#3209
8520e203b
Thanks @schibrikov! - Added ESM build to fix some bundling issues, more information can be found here
- Updated dependencies [
360e85462
,360e85462
]:- @xstate/[email protected]
- #2957
8550ddda7
Thanks @davidkpiano! - The repository links have been updated fromgithub.com/davidkpiano
togithub.com/statelyai
.
-
#2614
0f77ec36d
Thanks @DavKato! - Added new useSelector(actor, selector), which subscribes to actor and returns a svelte store that represents the selected state derived from selector(snapshot):<script> // It won't be updated unless the selected value changed. const value = useSelector(service, (state) => state.context.value); </script> <p>{$value}</p>