Skip to content

Instantly share code, notes, and snippets.

@benjdlambert
Created October 31, 2016 12:21
Show Gist options
  • Save benjdlambert/668fa683a03ea14a49199681e22d34e5 to your computer and use it in GitHub Desktop.
Save benjdlambert/668fa683a03ea14a49199681e22d34e5 to your computer and use it in GitHub Desktop.
function createContainer(ReactClass, options) {
return class Container extends React.Component {
setDataParams(dataParams) {
this.setState({ dataParams })
}
render() {
return <ReactClass setDataParams={this.setDataParams} />
}
}
}
class Component extends React.Component {
onScroll() {
this.props.setDataParams({ page: '1' })
}
render() {
<div>Current page {this.props.page.body.id}
}
}
export default createContainer(
Component, {
data(props, dataParams) {
return {
page: `/${dataParams.page}`
}
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment