View on GitHub

reading-notes

Learning Notes Repo for Code Fellows

State and Props

React lifecycle

click for more on react lifecycle

  1. the ‘render’ happens before ‘componentDidMount’
  2. The very first thing to happen in the lifecycle of React is mounting
  3. The order is: ‘constructor’, ‘render’, ‘React Updates’, ‘componentDidMount’, ‘componentWillUnmount’
  4. componentDidMount is where to set up any subscriptions and load anything using a network request or initialize the DOM

React State Vs Props

  1. you can pass the values of properties in the props
  2. the big difference between props and state is that props handle values outside the components and pass them into the component, and state is inside the components
  3. the component will re-render when the state of that component changes
  4. you can store anything that props pass into the component, such as numbers and strings

<==Back