Created
March 31, 2016 06:11
-
-
Save linuxenko/0271433314bc02ffe117be63569cf233 to your computer and use it in GitHub Desktop.
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
| import { connect } from 'react-redux'; | |
| import { Component } from 'react'; | |
| class SandwichShop extends Component { | |
| componentDidMount() { | |
| this.props.dispatch( | |
| makeASandwichWithSecretSauce(this.props.forPerson) | |
| ); | |
| } | |
| componentWillReceiveProps(nextProps) { | |
| if (nextProps.forPerson !== this.props.forPerson) { | |
| this.props.dispatch( | |
| makeASandwichWithSecretSauce(nextProps.forPerson) | |
| ); | |
| } | |
| } | |
| render() { | |
| return <p>{this.props.sandwiches.join('mustard')}</p> | |
| } | |
| } | |
| export default connect( | |
| state => ({ | |
| sandwiches: state.sandwiches | |
| }) | |
| )(SandwichShop); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment