Created
April 16, 2018 11:57
-
-
Save lmatteis/6ef439e3f9dc2fbeb757e58de176bc70 to your computer and use it in GitHub Desktop.
Use React-Statechart components together and have them talk with each-other
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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