Last active
December 6, 2018 22:13
-
-
Save Jahans3/4dbc491098732fce0080319b73f75aca to your computer and use it in GitHub Desktop.
Final ConnectState
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConnectState extends React.Component { | |
state = {}; | |
static getDerivedStateFromProps ({ state, mapState = s => s }) { | |
return mapState(state); | |
} | |
shouldComponentUpdate (nextProps, nextState) { | |
return shallowCompare(this.state, nextState); | |
} | |
render () { | |
return this.props.children({ | |
state: this.state, | |
dispatch: this.props.mapDispatch ? this.props.mapDispatch(this.props.dispatch) : this.props.dispatch | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment