Skip to content

Instantly share code, notes, and snippets.

@James-Byrne
Last active September 29, 2020 13:06
Show Gist options
  • Save James-Byrne/bccb2a4cd6186134a57b6458ecc2fd59 to your computer and use it in GitHub Desktop.
Save James-Byrne/bccb2a4cd6186134a57b6458ecc2fd59 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Test to show onEntry triggers on an internal transition to self
const onEntryMachine = Machine({
id: 'onEntryTest',
initial: 'initial',
context: {
retries: 0
},
states: {
initial: {
on: {
MOVE: 'elsewhere'
}
},
elsewhere: {
onEntry: ['logEntry'],
on: {
BACK: 'initial',
INTERNAL_TRANSITION: 'elsewhere',
}
},
},
}, {
actions: {
logEntry(context) {
console.log('onEntry > context', context);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment