Skip to content

Instantly share code, notes, and snippets.

@ryanflorence
Last active November 16, 2016 04:22
Show Gist options
  • Save ryanflorence/550a93226ae69f601eb0 to your computer and use it in GitHub Desktop.
Save ryanflorence/550a93226ae69f601eb0 to your computer and use it in GitHub Desktop.
class Profile extends React.Component {
// etc.
}
function createContainer (Component) {
return class extends React.Component {
render () {
return <Component {...this.props}/>
}
}
}
const Thing = createContainer(Profile, {
extra: 'stuff'
})
// createContainer is a factory not a "Higher Order Component"
// But `Thing` is a "Higher Order Component"
// because it renders a Profile, but then again ... doesn't
// every component render another component, and therefore
// qualifies as a higher-order component?
//
// So does "higher order component" mean something more than
// "a component that renders a component", and if so, what is
// the strict-ish definition of higher order component?
//
// Maybe `Thing` is a HOC because it is a component created by
// a factory that renders another component?
@ryanflorence
Copy link
Author

alright, i'll just get over it, bothers me that createContainer isn't actually a component, but is called a higher order component, definitely makes more sense when using plain function components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment