Skip to content

Instantly share code, notes, and snippets.

@hex13
Forked from jacekkolasa/hoc vs render function
Last active October 9, 2017 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hex13/a7ab4dbefbefbc92e119f8ec0747a9e5 to your computer and use it in GitHub Desktop.
Save hex13/a7ab4dbefbefbc92e119f8ec0747a9e5 to your computer and use it in GitHub Desktop.
a.js
// hoc
compose(
withState({a: 'setA', b: 'setB'}),
withProps(({ a, b }) => ({ c: a + b }))
);
// render function
return (
<div>
<WithState
config={{
a: 'setA', b: 'setB'
}}
render={({a, b, setA, 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