State and Props
React lifecycle
click for more on react lifecycle
- the ‘render’ happens before ‘componentDidMount’
- The very first thing to happen in the lifecycle of React is mounting
- The order is: ‘constructor’, ‘render’, ‘React Updates’, ‘componentDidMount’, ‘componentWillUnmount’
- componentDidMount is where to set up any subscriptions and load anything using a network request or initialize the DOM
React State Vs Props
- you can pass the values of properties in the props
- 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
- the component will re-render when the state of that component changes
- you can store anything that props pass into the component, such as numbers and strings