-
-
Save menor/aecd781759930f1b5096 to your computer and use it in GitHub Desktop.
Revisions
-
thmain revised this gist
Sep 13, 2014 . 1 changed file with 8 additions and 19 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,9 @@ /** * @jsx React.DOM */ var React = require('react'), MyReactComponent = React.createClass({ // The object returned by this method sets the initial value of this.state getInitialState: function(){ @@ -15,10 +20,7 @@ var MyReactComponent = React.createClass({ // Inspects this.state and this.props create the markup // Should never update this.state or this.props render: function(){ return (<div></div>); }, // An array of objects each of which can augment the lifecycle methods @@ -34,19 +36,16 @@ var MyReactComponent = React.createClass({ // Invoked once before first render componentWillMount: function(){ // Calling setState here does not cause a re-render }, // Invoked once after the first render componentDidMount: function(){ // You now have access to this.getDOMNode() }, // Invoked whenever there is a prop change // Called BEFORE render componentWillReceiveProps: function(nextProps){ // Not called for the initial render // Previous props can be accessed by this.props // Calling setState here does not trigger an an additional re-render @@ -56,32 +55,22 @@ var MyReactComponent = React.createClass({ // Called BEFORE a render // Not called for the initial render shouldComponentUpdate: function(nextProps, nextState){ // If you want the render method to execute in the next step // return true, else return false return true; }, // Called IMMEDIATELY BEFORE a render componentWillUpdate: function(nextProps, nextState){ // You cannot use this.setState() in this method }, // Called IMMEDIATELY AFTER a render componentDidUpdate: function(prevProps, prevState){ }, // Called IMMEDIATELY before a component is unmounted componentWillUnmount: function(){ } }); -
thmain revised this gist
Sep 13, 2014 . 1 changed file with 24 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,10 @@ var MyReactComponent = React.createClass({ // Inspects this.state and this.props create the markup // Should never update this.state or this.props render: function(){ console.log('render'); return (<div> <input type="button" onClick={this._handleClick}/> </div>); }, // An array of objects each of which can augment the lifecycle methods @@ -31,17 +34,19 @@ var MyReactComponent = React.createClass({ // Invoked once before first render componentWillMount: function(){ // Calling setState here does not cause a re-render console.log('componentWillMount'); }, // Invoked once after the first render componentDidMount: function(){ console.log('componentDidMount'); // You now have access to this.getDOMNode() }, // Invoked whenever there is a prop change // Called BEFORE render componentWillReceiveProps: function(nextProps){ console.log('componentWillReceiveProps'); // Not called for the initial render // Previous props can be accessed by this.props // Calling setState here does not trigger an an additional re-render @@ -51,21 +56,34 @@ var MyReactComponent = React.createClass({ // Called BEFORE a render // Not called for the initial render shouldComponentUpdate: function(nextProps, nextState){ console.log('shouldComponentUpdate'); // If you want the render method to execute in the next step // return true, else return false }, // Called IMMEDIATELY BEFORE a render componentWillUpdate: function(nextProps, nextState){ console.log('componentWillUpdate'); // You cannot use this.setState() in this method }, // Called IMMEDIATELY AFTER a render componentDidUpdate: function(prevProps, prevState){ console.log('componentDidUpdate'); }, // Called IMMEDIATELY before a component is unmounted componentWillUnmount: function(){ console.log('componentWillUnmount'); }, _handleClick: function(){ console.log('==Updating State==') this.setState({ 'key':'value' }); } }); module.exports = MyReactComponent; -
thmain revised this gist
Sep 13, 2014 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -41,7 +41,7 @@ var MyReactComponent = React.createClass({ // Invoked whenever there is a prop change // Called BEFORE render componentWillReceiveProps: function(nextProps){ // Not called for the initial render // Previous props can be accessed by this.props // Calling setState here does not trigger an an additional re-render @@ -50,18 +50,18 @@ var MyReactComponent = React.createClass({ // Determines if the render method should run in the subsequent step // Called BEFORE a render // Not called for the initial render shouldComponentUpdate: function(nextProps, nextState){ // If you want the render method to execute in the next step // return true, else return false }, // Called IMMEDIATELY BEFORE a render componentWillUpdate: function(nextProps, nextState)){ // You cannot use this.setState() in this method }, // Called IMMEDIATELY AFTER a render componentDidUpdate: function(prevProps, prevState){ }, -
thmain revised this gist
Sep 13, 2014 . 1 changed file with 19 additions and 19 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,19 @@ var MyReactComponent = React.createClass({ // The object returned by this method sets the initial value of this.state getInitialState: function(){ return {}; }, // The object returned by this method sets the initial value of this.props // If a complex object is returned, it is shared among all component instances getDefaultProps: function(){ return {}; }, // Returns the jsx markup for a component // Inspects this.state and this.props create the markup // Should never update this.state or this.props render: function(){ return (<div></div>); }, @@ -32,7 +32,7 @@ var MyReactComponent = React.createClass({ componentWillMount: function(){ // Calling setState here does not cause a re-render }, // Invoked once after the first render componentDidMount: function(){ @@ -46,7 +46,7 @@ var MyReactComponent = React.createClass({ // Previous props can be accessed by this.props // Calling setState here does not trigger an an additional re-render }, // Determines if the render method should run in the subsequent step // Called BEFORE a render // Not called for the initial render @@ -57,10 +57,10 @@ var MyReactComponent = React.createClass({ // Called IMMEDIATELY BEFORE a render componentWillUpdate: function(object nextProps, object nextState)){ // You cannot use this.setState() in this method }, // Called IMMEDIATELY AFTER a render componentDidUpdate: function(object prevProps, object prevState){ }, -
thmain revised this gist
Sep 13, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ var MyReactComponent = React.createClass({ // The object returned by this method sets the initial value of this.state getInitialState: function(){ return {}; }, -
thmain created this gist
Sep 13, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,71 @@ var MyReactComponent = React.createClass({ // The object returned by this method sets the initial value of this.state getInitialState: function(){ return {}; }, // The object returned by this method sets the initial value of this.props // If a complex object is returned, it is shared among all component instances getDefaultProps: function(){ return {}; }, // Returns the jsx markup for a component // Inspects this.state and this.props create the markup // Should never update this.state or this.props render: function(){ return (<div></div>); }, // An array of objects each of which can augment the lifecycle methods mixins: [], // Functions that can be invoked on the component without creating instances statics: { aStaticFunction: function(){} }, // -- Lifecycle Methods -- // Invoked once before first render componentWillMount: function(){ // Calling setState here does not cause a re-render }, // Invoked once after the first render componentDidMount: function(){ // You now have access to this.getDOMNode() }, // Invoked whenever there is a prop change // Called BEFORE render componentWillReceiveProps: function(object nextProps){ // Not called for the initial render // Previous props can be accessed by this.props // Calling setState here does not trigger an an additional re-render }, // Determines if the render method should run in the subsequent step // Called BEFORE a render // Not called for the initial render shouldComponentUpdate: function(object nextProps, object nextState){ // If you want the render method to execute in the next step // return true, else return false }, // Called IMMEDIATELY BEFORE a render componentWillUpdate: function(object nextProps, object nextState)){ // You cannot use this.setState() in this method }, // Called IMMEDIATELY AFTER a render componentDidUpdate: function(object prevProps, object prevState){ }, // Called IMMEDIATELY before a component is unmounted componentWillUnmount: function(){} });