Major Changes
-
#3947
5fa3a0c74
Thanks @davidkpiano! - Removed the ability to pass a factory function as argument touseMachine
. -
#4006
42df9a536
Thanks @davidkpiano! -useActorRef
is introduced, which returns anActorRef
from actor logic:const actorRef = useActorRef(machine, { ... }); const anotherActorRef = useActorRef(fromPromise(...));
is deprecated in favor ofuseMachine
useActor
, which works with machines and any other kind of logic-const [state, send] = useMachine(machine); +const [state, send] = useActor(machine); const [state, send] = useActor(fromTransition(...));
is removed in favor ofuseSpawn
useActorRef
-const actorRef = useSpawn(machine); +const actorRef = useActorRef(machine); The previous use of `useActor(actorRef)` is now replaced with just using the `actorRef` directly, and with `useSelector`: ```diff -const [state, send] = useActor(actorRef); +const state = useSelector(actorRef, s => s); // actorRef.send(...)
-
#4050
fc88dc8e6
Thanks @davidkpiano! - Theoptions
prop has been added (back) to theContext.Provider
component returned fromcreateActorContext
:const SomeContext = createActorContext(someMachine); // ... <SomeContext.Provider options={{ input: 42 }}> {/* ... */} </SomeContext.Provider>;
-
#4006
42df9a536
Thanks @davidkpiano! -useActor
has been removed from the created actor context, you should be able to replace its usage withMyCtx.useSelector
andMyCtx.useActorRef
. -
#4265
1153b3f9a
Thanks @davidkpiano! - FSM-related functions have been removed. -
#3947
5fa3a0c74
Thanks @davidkpiano! - Implementations for machines onuseMachine
hooks should go directly on the machine viamachine.provide(...)
, and are no longer allowed to be passed in as options.-const [state, send] = useMachine(machine, { - actions: { - // ... - } -}); +const [state, send] = useMachine(machine.provide({ + actions: { + // ... + } +}));
-
#3148
7a68cbb61
Thanks @davidkpiano! - RemovedgetSnapshot
parameter from hooks. It is expected that the receivedactorRef
has to have agetSnapshot
method on it that can be used internally.
Minor Changes
- #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. - #4240
409552cf8
Thanks @davidkpiano! - TheuseMachine
function is an alias ofuseActor
. - #4436
340aee643
Thanks @Andarist! - Fast refresh now works as expected for most use-cases. - #4050
fc88dc8e6
Thanks @davidkpiano! - TheobserverOrListener
argument has been removed from the 3rd argument ofcreateActorContext(logic, options)
.