-
This works: SELECT: {
target: 'filled',
actions: assign((context, event) => ({
selected: event.selected
}))
}, But is does not work: actions: {
selecting: assign((context, event) => ({
selected: event.selected
}))
}, I'd like to DRY & be able to update the context:Selected from both states. Worked on this for over an hour & I'm stuck :/ |
Beta Was this translation helpful? Give feedback.
Answered by
Andarist
Sep 30, 2020
Replies: 1 comment 2 replies
-
It works - you have just made a mistake. const radioGroup = Machine(
{
id: "radioGroup",
initial: "emptied",
context: {
selected: "",
},
states: {
emptied: {
on: {
SELECT: {
target: "filled",
actions: ["selecting"],
},
},
},
filled: {
on: {
SELECT: {
actions: ["selecting"],
},
},
},
},
},
{
actions: {
selecting: assign((context, event) => ({
selected: event.selected,
})),
},
}
); |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
tomByrer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It works - you have just made a mistake.
actions
is a part of the second argument of theMachine
/createMachine
and not part of the first one. So your machine should look like this: