Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
XState: Guarded Transitions from `done.invoke.<service>`
...
validating: {
invoke: {
src: 'validateMobileNumber',
onDone: [
{
target: 'valid',
actions: assign({mobileNumberError: ''}),
cond: (_ctx, event) => {
const validationResponse = event.data;
if (validationResponse.result) {
return true;
} else {
return false;
}
}
},
// If the condition is false, validation failed, so go to invalid
{
target: 'invalid',
actions: assign((_ctx, event) => ({ mobileNumberError: event.data.validationMessage }))
}
],
onError: { ... }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment