Let's get to know 3 basic criteria to define what is part of the state and what is not. These criteria allow me to decide with complete confidence the "minimal but complete representation of the state" in my daily life as a React Lover.
Even though we know that state is immutable, it is usually tied to a part of the interface that is mutable. So as a first criterion we must evaluate if we have a part of the UI that is expected to change from that value, it is very likely that we are dealing with a candidate to be state, but first evaluate the following two criteria.
If the value that defines the candidate to become a state is received from another component then it must not be a state. It's possible that it is a state in the component that originally inherits it but not the component that receives it.
If the value must be calculated using another state as a base then it is not a state, and its interaction in the interface must be shown from the calculation of the original state.
The above is the detailed content of How to define the state?. For more information, please follow other related articles on the PHP Chinese website!