util for reset context to their initial values #5112
Unanswered
cringelord1940
asked this question in
Ideas
Replies: 1 comment
-
You can do this by storing the static context outside of the machine: const initialContext = { count: 0 }
const machine = setup({ ... }).createMachine({
context: initialContext
}) For input, you can store the input on context: const machine = setup({ ... }).createMachine({
context: ({ input }) => ({
input,
// the rest of your context
})
}) And use that A built-in "reset" action would mean that we'd have to implicitly store that initial context inside the state, and it's probably better for that kind of state to be explicitly stored by the developer. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I find this to be useful for a software flow to rerun
Beta Was this translation helpful? Give feedback.
All reactions