Axios and Component State

What is State?

In anytime that we change the state of the component, the component will automatically render itself to the mobile devices screen

3 steps to implement State

  1. Set default or initial state for the class component

  2. Get the data and tell component’s state to update

Use this.setState({}) will auto trigger the UI update

Make sure that the component makes use of the state

When setState is called, it will trigger render()

Rule of State

  • Definition of state: a plain javascript object used to record and respond to user-triggered events.

  • When we need to update what a component shows, call this.setStates

  • Only change state with setStateI, do not do this.state

Last updated

Was this helpful?