reading notes for code fellows
The difference between state and props will be very important to know when it comes to figuring out which one needs to be used in any specific situation going forward, and I imagine the React lifecycle will helpful to understand when it comes to knowing where things need to go so everything happens in the correct order.
React allows you to define components as classes or functions, and the methods that you can use on them, which can be called during the lifecycle of a component and allow you to update the UI and application status, are called lifecycle events. The three phases of the component lifecycle are
The constructor() for a React component is called before mounting occurs. If it is a subclass, you also need to call super(props). Constructors can use this.state to assign state or can bind event handlers to an instance.
The only method actually required in a class component is render(), which examines this.state and this.props whenever it is called.
componentDidMount() runs after a component is mounted and should be used to load anything using a network request or to initialize the DOM.
If you set shouldComponentUpdate() to false, it won’t automatically rerender after every state change, which helps to optimize performance.
componentDidUpdate() is used to perform network requests after a change has occurred.
componentWillUnmount() allows you to clean up the DOM/network requests.
What exactly are network requests/subscriptions in the context this article is using them?