Skip to content

Instantly share code, notes, and snippets.

@lmatteis
Created April 16, 2018 11:57
Show Gist options
  • Save lmatteis/6ef439e3f9dc2fbeb757e58de176bc70 to your computer and use it in GitHub Desktop.
Save lmatteis/6ef439e3f9dc2fbeb757e58de176bc70 to your computer and use it in GitHub Desktop.
Use React-Statechart components together and have them talk with each-other
function ShowNumberOfAccounts(props) {
return props.numberOfAccounts
}
withStatechart(function reducer(state = {}, event) {
switch (event.type) {
case ACCOUNTS:
return {
...state,
numberOfAccounts: accounts.length
}
default:
return state
}
})(ShowNumberOfAccounts)
<Accounts
onAction={action =>
// action = { type: ACCOUNTS, payload: [...] }
// called every-time statechart outputs an action
}
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment