Skip to content

Instantly share code, notes, and snippets.

@jacekkolasa
Last active October 9, 2017 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jacekkolasa/9a1c091b18194140da65bae5f956df71 to your computer and use it in GitHub Desktop.
Save jacekkolasa/9a1c091b18194140da65bae5f956df71 to your computer and use it in GitHub Desktop.
// hoc
compose(
withState('a', 'setA'),
withState('b', 'setB'),
withProps(({ a, b }) => ({ c: a + b }))
);
// render function
return (
<div>
<WithState
config={['a', 'setA']}
render={({a, setA}) => (
<WithState
config={['b', 'setB']}
render={({b, setB}) => (
<WithProps
config={({ a, b }) => ({ c: a + b })}
render={({ c }) => (
<div>
{c}
</div>
)}
/>
)}
/>
)}
/>
</div>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment