Skip to content

Instantly share code, notes, and snippets.

@yokesharun
Created July 6, 2018 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yokesharun/6e67262e8b7819030571e0ba5f2573af to your computer and use it in GitHub Desktop.
Save yokesharun/6e67262e8b7819030571e0ba5f2573af to your computer and use it in GitHub Desktop.
React State and props Initialisation and manupulation
// 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