1

PropsvsState&LiftingState[EN][ES]

Normally these two can create confusion, but don’t worry it is easy to understand how to use them once you see the differences between them.

You can see more about the difference between this two elements here

Props

These features allow communication between the father component and its child, creating a binding where the father keeps the logic and the child represents that data. This is the main causer of bugs in React adding the creation of “wrapper hells” in our Application. React, to solve this created Hooks.

State

There are some variables that are unique from the component, for those cases we initialize a state object so later on, we can set (setState) them and update their values inside the element.

Lifting state up -official info-

Technique we can use to lift a state up to a closest parent. When do we need to do so? specially when we have two or more inputs which values are sync on change events. For example, Celcius and Fahrenheit inputs. So the technique tell us to situate a state in the parent component as source of truth so if one input is modified the parent will calculate both results and sent this to its children through props.

PropiedadesvsEstados&Levantando Estados [ES]

  • Normalmente, estos dos pueden crear confusión, pero no se preocupe, es fácil entender cómo usarlos una vez que vea las diferencias entre ellos. *

  • Puede ver más sobre la diferencia entre estos dos elementos [aquí] (https://flaviocopes.com/react-state-vs-props/) *

Accesorios

Estas características permiten la comunicación entre el componente padre y su hijo, creando un vínculo donde el padre mantiene la lógica y el hijo representa esos datos. Este es el principal causante de errores en React al agregar la creación de “infiernos envoltorios” en nuestra Aplicación. Reacciona, para resolver este Hooks creado.

Estado

Hay algunas variables que son únicas del componente, para esos casos inicializamos un objeto de estado para que más adelante podamos establecerlas (setState) y actualizar sus valores dentro del elemento.

Levantando el estado [-información oficial-] (https://reactjs.org/docs/lifting-state-up.html)

Técnica que podemos usar para elevar un estado hasta un padre más cercano. ¿Cuándo debemos hacerlo? especialmente cuando tenemos dos o más entradas cuyos valores están sincronizados en eventos de cambio. Por ejemplo, entradas de Celsius y Fahrenheit. Entonces, la técnica nos dice que situemos un estado en el componente padre como fuente de verdad, de modo que si se modifica una entrada, el padre calculará ambos resultados y lo enviará a sus hijos a través de accesorios.

Escribe tu comentario
+ 2