Created
August 13, 2015 19:03
-
-
Save pedroparra/447ceee8d35e1d91a6dc to your computer and use it in GitHub Desktop.
React Js componentWillReceiveProps
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
| // Ecmascript 5 | |
| var MyComponent = React.createClass({ | |
| componentWillReceiveProps: function(next_props){ | |
| this.setState({ loading: true }); | |
| }, | |
| render: function() { | |
| className = this.state.loading ? 'loading' : 'loaded'; | |
| return(<div className={className}>Soy un component</div>) | |
| } | |
| }); | |
| // Ecmascript 6 | |
| class MyComponent extends React.Component { | |
| componentWillReceiveProps(next_props) { | |
| this.setState({ loading: true }); | |
| } | |
| render(){ | |
| className = this.state.loading ? 'loading' : 'loaded'; | |
| return(<div className={className}>Soy un component</div>) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment