Author - StudySection Post Views - 41 views
Uni-directional | React JS

Uni-directional or one-way data flow in React JS

What is the uni-directional data flow?

In React, the state is used to store the data related to the components and pass that state as pros(data coming from parents is being called props) to the child components
Phenomena of passing data from parent to child component are called the uni-directional or one-way data flow.

The uni-directional data flow has some advantages, these are

  1. Easier debugging
  2. Less prone to errors
  3. it’s more efficient because the library already knows what the boundaries are of each part of the system

Changing the state of a component will never affect its parent or the siblings, only the children will be affected. This is the main reason that the state is often moved up in the component tree so that it can be shared between the components that need to access it.

But there are certain situations where we need to pass the data from the child to the parent component:
In that case, we can store the state in the nearest Parent component and then pass the data as props to the child components and Parent component can make the necessary state change and the new state gets passed to its child components.

Get certification for your knowledge in the fundamentals of Computer functioning by clearing the Computer Certification exam conducted by StudySection. After going through this Computer Certification Exam, you will be able to evaluate your basic knowledge of computers.

Leave a Reply

Your email address will not be published.