getDerivedStateFromProps
getDerivedStateFromProps is a static method in React class components. It is called before the render method, both for the initial mount and for subsequent updates. Its primary purpose is to update the component's state in response to changes in its props. This method receives two arguments: the current props and the current state. It should return an object to update the state, or null if no state update is needed.
This lifecycle method is useful for deriving state from props. For example, if a component needs to
It is important to note that getDerivedStateFromProps should not have side effects. It is solely for calculating