Redux Flashcards

1
Q

What is Redux?

A

A state management library.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the three principles that Redux follows?

A

<b>Single source of truth</b>: The state of the entire application is stored in an object/ state tree within a single store. The single state tree makes it easier to keep track of changes over time and debug or inspect the application.
<b>State is read-only</b>: The only way to change the state is to trigger an action. An action is a plain JS object describing the change. Just like state is the minimal representation of data, the action is the minimal representation of the change to that data.
<b>Changes are made with pure functions</b>: In order to specify how the state tree is transformed by actions, you need pure functions. Pure functions are those whose return value depends solely on the values of their arguments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What do you understand by “Single source of truth”?

A

Redux uses ‘Store’ for storing the application’s entire state at one place.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

List down the components of Redux.

A

Action, Reducer, Store, and View.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Explain the role of Reducer.

A

Reducers are pure functions which specify how the application’s state changes in response to an ACTION. Reducers work by taking in the previous state and action, and then it returns a new state. It determines what sort of update needs to be done based on the type of the action, and then returns new values. It returns the previous state as it is, if no work needs to be done.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the significance of Store in Redux?

A

A store is a JavaScript object which can hold the application’s state and provide a few helper methods to access the state, dispatch actions and register listeners. The entire state/ object tree of an application is saved in a single store. As a result of this, Redux is very simple and predictable. We can pass middleware to the store to handle the processing of data as well as to keep a log of various actions that change the state of stores. All the actions return a new state via reducers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly