ReactJS Interview Questions and Answers
Question - 101 : - What were the major problems with MVC framework?
Answer - 101 : -
The major problems with the MVC framework are:
- DOM manipulation was very expensive.
- It makes the application slow and inefficient.
- There was a huge memory wastage.
- It makes the application debugging hard.
Question - 102 : - What are the three principles that Redux follows?
Answer - 102 : -
The three principles that redux follows are:
- Single source of truth: The State of your entire application is stored in an object/state tree inside a single Store. The single State tree makes it easier to keep changes over time. It also makes it easier to debug or inspect the application.
- The State is read-only: There is only one way to change the State is to emit an action, an object describing what happened. This principle ensures that neither the views nor the network callbacks can write directly to the State.
- Changes are made with pure functions: To specify how actions transform the state tree, you need to write reducers (pure functions). Pure functions take the previous State and Action as a parameter and return a new State.
Question - 103 : - List down the components of Redux.
Answer - 103 : -
The components of Redux are given below.
- STORE: A Store is a place where the entire State of your application lists. It is like a brain responsible for all moving parts in Redux.
- ACTION: It is an object which describes what happened.
- REDUCER: It determines how the State will change.
Question - 104 : - Explain the role of Reducer.
Answer - 104 : -
Reducers read the payloads from the actions and then updates the Store via the State accordingly. It is a pure function which returns a new state from the initial State. It returns the previous State as it is if no work needs to be done.
Question - 105 : - What is the significance of Store in Redux?
Answer - 105 : -
A Store is an object which holds the application's State and provides methods to access the State, dispatch Actions and register listeners via subscribe(listener). The entire State tree of an application is saved in a single Store which makes the Redux simple and predictable. We can pass middleware to the Store which handles the processing of data as well as keep a log of various actions that change the Store's State. All the Actions return a new state via reducers.
Question - 106 : - What are the advantages of Redux?
Answer - 106 : -
The main advantages of React Redux are:
- React Redux is the official UI bindings for react Application. It is kept up-to-date with any API changes to ensure that your React components behave as expected.
- It encourages good 'React' architecture.
- It implements many performance optimizations internally, which allows to components re-render only when it actually needs.
- It makes the code maintenance easy.
- Redux's code written as functions which are small, pure, and isolated, which makes the code testable and independent.