State Management with Redux

Last Updated :
Discuss
Comments

Question 1

Which of the following is true about redux?

  • A

    Redux is a predictable state container for JavaScript apps

  • B

    Redux fundamental principles help in maintaining consistency throughout your application

  • C

    Redux makes debugging and testing easier

  • D

    All of the above

Question 2

Actions and states are held together by a function called?

  • A

    Reducer

  • B

    Redux

  • C

    suscribe

  • D

    view

Question 3

What is Redux primarily used for in React applications?

  • A

    Fetching data from the API

  • B

    Managing application state

  • C

    Styling components

  • D

    Routing

Question 4

Which of the following is the core principle of Redux?

  • A

    One-way data flow

  • B

    Two-way data binding

  • C

    Functional components only

  • D

    Component-level state management

Question 5

What does an action in Redux contain?

  • A

    The logic to modify the state

  • B

    Only data required to modify the state

  • C

    The current state of the app

  • D

    The view of the component

Question 6

Which function is used to combine multiple reducers into one in Redux?


  • A

    combineActions()

  • B

    combineReducers()

  • C

    createReducer()

  • D

    mergeReducers()

Question 7

Given the following reducer, what is the output of store.getState() if store.dispatch({ type: 'INCREMENT' }) is called?

JavaScript
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());


  • A

    { count: 0 }

  • B

    { count: 1 }

  • C

    undefined

  • D

    Error

Question 8

How do you dispatch an action to Redux store?

  • A

    store.dispatch()

  • B

    store.update()

  • C

    store.set()

  • D

    dispatch.store()

Question 9

What will be the new state after the following code is executed?

JavaScript
//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' });
  • A

    { name: 'Raj' }

  • B

    { name: 'Aryan' }

  • C

    { name: 'Aryan', payload: 'Aryan' }

  • D

    undefined

Question 10

What is the primary difference between Redux and React's Context API?

  • A

    Redux is used for component styling, while Context API is used for state management.

  • B

    Redux offers built-in dev tools, while Context API does not.

  • C

    Redux is a part of React, while Context API is an external library.

  • D

    Context API manages state across the entire app, while Redux manages state locally.

There are 10 questions to complete.

Take a part in the ongoing discussion