Member-only story

ReactJS Interview Prep: Unidirectional Data flow

Marika Lam
1 min readJun 18, 2024

--

What is Unidirectional Data Flow?

  • It is a technique that is mainly found in functional reactive programming
  • It means that data has one, and only one way to be transferred to other parts of the application
  • It means that the child components are not able to update the data that is coming from the parent component. In React, data coming from a parent is called props.

State change in React

  • State is always owned by one component.
  • Any changes made by this state can only affect the components below it (ex. its children). Changing state will never affect its parent or its siblings.

Advantages of unidirectional data flow

  1. Debugging: One-way data flow makes debugging much easier.
  2. Better control: Having data flow in one direction makes the program less prone to errors and gives the developer more control
  3. Efficiency: As the used libraries are wary of the limitations and specifications of the one-way flow, extra resources are not wasted, leading to a more efficient process.

--

--

No responses yet