Created
July 6, 2018 17:14
-
-
Save yokesharun/6e67262e8b7819030571e0ba5f2573af to your computer and use it in GitHub Desktop.
React State and props Initialisation and manupulation
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
// Define a state | |
this.state = { | |
name: "Jon Snow", | |
age: 28 | |
} | |
// get value of the state | |
this.state.name | |
this.state.age | |
// to get State | |
this.setState({ | |
name: "Arya Stark" | |
age: 25 | |
}) | |
// to pass a props | |
<ChildComponent propsName={this.state.propsValue} /> | |
// Get Props value | |
this.props.propsName // it will return the propsName value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment