REACT Component Lifecycle

PHOTO EMBED

Wed Apr 27 2022 14:00:43 GMT+0000 (Coordinated Universal Time)

Saved by @vankoosh #javascriptreact

import React from 'react';

export default class Mario extends React.Component {
  componentWillMount(){
    console.log("Component will mount"); //if you set this.setState({}) here, it will set the state before the first render
  }

  componentDidMount() {
    console.log("Component did mount");
  }

  componentWillReceiveProps(nextProps) {
    console.log(`Component will receive as next props: ${nextProps}`);
  }

  shouldComponentUpdate(nextProps,nextState) {
    console.log(`Should the comp update, it should update with ${nextProps} and/or ${nextState}`);
    return true;         //answer if it should/should not update
  }

  componentWillUpdate

  render() {
    return ()
  }
}
content_copyCOPY