Skip to content

Instantly share code, notes, and snippets.

@hubgit
Forked from osmelmora/child-as-func-vs-hocs.js
Last active July 26, 2017 12:52
Show Gist options
  • Save hubgit/093834cba055a211a815165daecdd147 to your computer and use it in GitHub Desktop.
Save hubgit/093834cba055a211a815165daecdd147 to your computer and use it in GitHub Desktop.
// child functions
export default (
<Connect mapStateToProps={mapStateToProps} mapDispatchToProps={mapDispatchToProps}>
{props => (
<WithRouter>
{router => (
<Foo router={router} {...props}/>
)}
</WithRouter>
)}
</Connect>
)
// render functions
export default (
<Connect mapStateToProps={mapStateToProps} mapDispatchToProps={mapDispatchToProps} render={props => (
<WithRouter render={router => (
<Foo router={router} {...props}/>
)}>
)}/>
)
// compose
export default compose(
connect(mapStateToProps, mapDispatchToProps),
withRouter
)(Foo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment