Answers for "componentdidmount"

0

componentdidmount

import React, { Component } from 'react';

class App extends Component {

  constructor(props){
    super(props);
    this.state = {
      data: 'Jordan Belfort'
    }
  }

  getData(){
    setTimeout(() => {
      console.log('Our data is fetched');
      this.setState({
        data: 'Hello WallStreet'
      })
    }, 1000)
  }

  componentDidMount(){
    this.getData();
  }

  render() {
    return(
      <div>
      {this.state.data}
    </div>
    )
  }
}

export default App;
Posted by: Guest on June-17-2021
0

shouldcomponentupdate

shouldComponentUpdate(nextProps, nextState) {
  return true;
}
Posted by: Guest on June-08-2020
2

component did mmount

componentDidMount()
Posted by: Guest on May-01-2020
2

component did mmount

componentDidUpdate(prevProps, prevState, snapshot)
Posted by: Guest on May-01-2020

Code answers related to "componentdidmount"

Browse Popular Code Answers by Language