Redux Interview Questions and Answers
It is most commonly used with libraries such as React or Angular for building user interfaces.
While making communication between two components that don't have a parent-child relationship, this is the case where Redux comes in handy.
- Redux offers a solution of storing all your application state in one place, called a "store".
- Components then "dispatch" state changes to the store, not directly to other components.
- The components that need to be aware of state changes can "subscribe" to the store.
- The store can be thought of as a "middleman" for all state changes in the application.
- With Redux involved, components don't communicate directly with each other, but rather all state changes must go through the single source of truth, the store.
Redux provides an easy way to centralize the state of your application
You may also like - Node Js Interview Questions
Redux is available as a package on NPM.
npm install --save redux
Redux can be described in three fundamental principles
- Single source of truth
- State is read-only
- Changes are made with pure functions
The state of your whole application is stored in an object tree within a single store.
The only way to change the state is to emit an action, an object describing what happened.OR
Your state should be read-only and can only be modified through actions
To specify how the state tree is transformed by actions, you write pure reducers.
Flux is a Design Pattern and Redux is a library
|Single Store||Multiple Store|
|It offers interesting features such as writing applications, testing in different environments such as a server, client, etc.||It is an observer pattern that is modified to fit React.|
|In redux, actions can be functions or promises.||It is a fancy name given to observer pattern and Facebook has developed tools to aid the implementation of these patterns.|
You may also like - React Js Interview Questions