I have a simple state machine that handles an input form
export const chatMachine = Machine({
id: 'chat',
initial: 'idle',
states: {
idle: {
on: {
SET_MESSAGE: { actions: ['handleMessageChange'] },
COMMENT_SUBMITTED: {
actions: ['submitComment']
}
}
}
}
});
I would like the submitComment
action to fire off a function and then reset a field in context like this:
submitComment: (ctx, e) => {
e.payload(ctx.message);
assign({
message: ''
});
}
This doesn't work.
It fires the method I'm passing in but it doesn't make it to the assign bit.
Can I do two thing sin one action or should I be creating two seperate actions?