InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
How is Relay different from Redux? |
||||||
Answer»
|
|||||||
| 2. |
What is Redux Thunk? |
|
Answer» Redux THUNK middleware is something that allows the developers to WRITE the action creators that return functions, not actions. The redux-thunk can also be used for postponing the dispatch of action or to dispatch just if a specific condition is met. The INNER function gets the “STORE” methods dispatch and getState() as the parameters. |
|
| 3. |
What is the purpose of the constants in Redux? |
|
Answer» When you use an IDE, the constants allow you to find all the USAGES of specific FUNCTIONALITY ACROSS the PROJECT. It also prevents you from making silly mistakes which are usually caused by typos; in that case, you will receive a Reference Error IMMEDIATELY. |
|
| 4. |
What are reducers in redux? |
|
Answer» The reducers in redux are the pure functions that take the previous state and an action, and then it returns to the NEXT state. It is known as the reducer because they are the TYPE of function that would pass to Array.prototype.reduce(reducer, ?initialValue). It is very essential to ensure that the reducer stays pure. To MAINTAIN this, there are few things that you should never do INSIDE the reducer:
const initialState = { value: 0 } function counterReducer(state = initialState, action) { |
|
| 5. |
What are the downsides of Redux compared to Flux? |
|
Answer» Instead of downsides, there are few COMPROMISES of using Redux over Flux that is listed below:
|
|
| 6. |
How to structure Redux top-level directories? |
|
Answer» All the applications have multiple top-level directories as mentioned below:
|
|
| 7. |
How to access redux stores outside a react component? |
|
Answer» To access the REDUX stores outside a react COMPONENT, you need to export the store from the MODULE where it has been created with createStore. NOTE: If you are looking for React Native INTERVIEW Questions then you can visit here. Examplestore = createStore(myReducer); |
|
| 8. |
What is the difference between React context and React redux? |
||||||
Answer»
|
|||||||
| 9. |
How to add multiple middlewares to Redux? |
|
Answer» For adding multiple middlewares to Redux, you can use applyMiddleware by which the developer can pass each piece of middleware as the NEW or ANOTHER argument. As per your preferences, you just need to pass every SINGLE piece of middleware. For instance, one can add the Redux THUNK and the LOGGER middleware as the argument just as below: Exampleimport { createStore, applyMiddleware } from 'redux' |
|
| 10. |
What is “store” in redux? |
|
Answer» The Redux “STORE” carries together all the states, REDUCERS, and actions that CREATE the app. The store has multiple responsibilities:
import { createStore } from 'redux' function addTodo(text) { store.dispatch(addTodo('Read the docs')) |
|
| 11. |
What is an action in Redux? |
|
Answer» Actions are the plain JavaScript objects which contain a type field. ACTION can be considered as an event that can describe something that has HAPPENED in the application. Always remember actions should contain a small amount of information that is needed to mention what has happened. Also READ: Next js Interview QuestionsExampleconst addTodoAction = { |
|
| 12. |
What is Redux DevTools? Also, explain the features of Redux DevTools? |
|
Answer» It is a time TRAVEL environment that allows live editing for Redux with action replay, hot reloading, and customizable UI. For your EASE, you can also use the extension of Redux DevTools in any of your BROWSERS, Chrome, or firefox. Major features of Redux DevTools are:
If you want to READ more about this TOPIC in detail then you can visit here. |
|
| 13. |
Do you need to keep all component states in the Redux store? |
|
Answer» You do not need to push everything in the redux store as you have to keep your application state as small as POSSIBLE. You should only do it if it MAKES a difference to you to keep something there or MAYBE helping you in making your LIFE easier while using Dev Tools. |
|
| 14. |
What is the difference between mapStateToProps() and mapDispatchToProps()? |
||||||||
Answer»
|
|||||||||
| 15. |
What are the core principles of Redux? |
|
Answer» There are three core principles that Redux follows:
NOTE: If you WANT to learn more about Redux then you can visit here. |
|