Answers for "USE OF COMPONENTDIDMOUNT()"

0

USE OF COMPONENTDIDMOUNT()

// good place to call setState here

componentDidMount(){
  this.setState({
    message: 'i got changed',
  });
}

---

// or to make request to the server

componentDidMount() {
    fetch('https://api.mydomain.com')
      .then(response => response.json())
      .then(data => this.setState({ message: data.message }));
  }
Posted by: Guest on October-15-2021

Code answers related to "USE OF COMPONENTDIDMOUNT()"

Code answers related to "Javascript"

Browse Popular Code Answers by Language