Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

react
javascript
data
flux

What are the two fundamental laws of Flux?

Educative Answers Team

Flux

Flux is a data manipulation architecture in React. It offers a substitute for the normal way of transferring data within React applications by passing data into children components.

Flux uses a store to manage the state. Actions in the application trigger acts of data storage. Actions are then passed by the dispatcher into the store, which allows views to display data according to the current state.

svg viewer

Fundamental rules of Flux

There are two fundamental rules of when Flux should be used:

  1. A piece of data needs to be used in multiple locations in the application, but passing it via components breaks the Single Responsibility Principle or simply does not make sense.

For this issue, the stores offer an alternative solution to accessing data that is different than passing it through components. Hence, the use of Flux maintains the Single Responsibility Principle.

  1. There are multiple actors that may change the data.

This issue ensures consistency in data manipulation. When more than one actor can change data, it is important that the operations are carried out serially. Flux supposedly ensures this by using serializable action queues.

RELATED TAGS

react
javascript
data
flux
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring