Home >Web Front-end >JS Tutorial >How to define the state?

How to define the state?

DDD
DDDOriginal
2024-11-14 12:40:02863browse

¿Cómo definir el estado?

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.

Criterion 1: Expected to change.

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.

Criterion 2: It should not be inherited from any component

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.

Criterion 3: Should not be calculated from another state

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn