Skip to content

Latest commit

 

History

History
43 lines (28 loc) · 1.71 KB

2-1-react-state-and-lifecycle.md

File metadata and controls

43 lines (28 loc) · 1.71 KB

Ironhack Logo

React | State and Lifecycle

About the state

// You can initialize the state in the Component's constructor
this.state = { firstname: 'Maxence', age: 25 }

// You can get a state value with "this.state" property
this.state.firstname

// You MUST set some state value with "this.setState" method
// Be careful, this opereation might be asynchronous
this.setState({firstname: 'Mickaël'})

About React Lifecycle

Mounting:

Updating:

Unmounting:

Error Handling:

Exercise

On this Codepen, by using axios, display in the App component the information from this API: https://ih-crud-api.herokuapp.com/characters/1