Here’s a quiz to test your knowledge of Redux! Dive into key concepts like reducers, actions, and state management
Question 1
What is Redux primarily used for in React applications?
Fetching data from the API
Managing application state
Styling components
Routing
Question 2
Which of the following is true about redux?
Redux is a predictable state container for JavaScript apps
Redux fundamental principles help in maintaining consistency throughout your application
Redux makes debugging and testing easier
All of the above
Question 3
Actions and states are held together by a function called?
Reducer
Redux
suscribe
view
Question 4
Which of the following is the core principle of Redux?
One-way data flow
Two-way data binding
Functional components only
Component-level state management
Question 5
What does an action in Redux contain?
The logic to modify the state
Only data required to modify the state
The current state of the app
The view of the component
Question 6
Which function is used to combine multiple reducers into one in Redux?
combineActions()
combineReducers()
createReducer()
mergeReducers()
Question 7
Given the following reducer, what is the output of store.getState() if store.dispatch({ type: 'INCREMENT' }) is called?
const counterReducer = (state = { count: 0 }, action) => {
switch (action.type) {
case "INCREMENT":
return { count: state.count + 1 };
default:
return state;
}
};
const store = Redux.createStore(counterReducer);
store.dispatch({ type: "INCREMENT" });
console.log(store.getState());
{ count: 0 }
{ count: 1 }
undefined
Error
Question 8
How do you dispatch an action to Redux store?
store.dispatch()
store.update()
store.set()
dispatch.store()
Question 9
What will be the new state after the following code is executed?
//reducer
const nameReducer = (state = { name: 'Raj' }, action) => {
switch (action.type) {
case 'CHANGE_NAME':
return { ...state, name: action.payload };
default:
return state;
}
};
//dispatch call
dispatch({ type: 'CHANGE_NAME', payload: 'Aryan' });
{ name: 'Raj' }
{ name: 'Aryan' }
{ name: 'Aryan', payload: 'Aryan' }
undefined
Question 10
What is the primary difference between Redux and React's Context API?
Redux is used for component styling, while Context API is used for state management.
Redux offers built-in dev tools, while Context API does not.
Redux is a part of React, while Context API is an external library.
Context API manages state across the entire app, while Redux manages state locally.
There are 10 questions to complete.