Sharing configurations between multiple states. #1394
Answered
by
davidkpiano
dustinknopoff
asked this question in
General
-
Let's say I have 2 states that should handle all the same events, in the same way except for a single event/action. What's the best way to create the machine config for this? Right now I have it as: const logicEvents = {
SET_INDEX: {
target: "idle",
actions: ["setIndex"],
//...
},
}; and in my config: loaded: {
on: {
...logicEvents,
ADD_UNDO_REDO: {
actions: ["addUndoRedo"],
},
},
},
undo_redo: {
on: {
...logicEvents,
},
}, This works but typescript is unhappy with the typing. (I'm not sure what type |
Beta Was this translation helpful? Give feedback.
Answered by
davidkpiano
Aug 19, 2020
Replies: 1 comment 1 reply
-
✏️ Please create a CodeSandbox (XState TypeScript template) reproduction of this. Thanks! |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
dustinknopoff
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
✏️ Please create a CodeSandbox (XState TypeScript template) reproduction of this. Thanks!