Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

React Component Did Mount Function

class App extends React.Component {

  state = {
    foo: false,
  };

  componentDidMount() {
    console.log('componentDidMount() lifecycle');

    // Trigger update
    this.setState({ foo: !this.state.foo });
  }

  render() {
    console.log('Render lifecycle')
    return <h1>Hello</h1>
  }
}
Source by linguinecode.com #
 
PREVIOUS NEXT
Tagged: #React #Component #Did #Mount #Function
ADD COMMENT
Topic
Name
9+2 =