Unit 6: Redux, Debugging and Deployment - Practice Quiz

INT252 — Web App Development With Reactjs 50 Questions
0 Correct 0 Wrong 50 Left
0/50

1 What is Redux primarily used for in a React application?

A. Database management
B. Routing
C. State management
D. Server-side rendering

2 Which of the following is NOT one of the three fundamental principles of Redux?

A. Single source of truth
B. Changes are made with pure functions
C. State is read-only
D. State is distributed across components

3 In Redux, what is the 'Store'?

A. An object that holds the application state
B. A middleware for API calls
C. A component that renders UI
D. A function that changes state

4 What is the purpose of a 'Reducer' in Redux?

A. To specify how the application's state changes in response to actions
B. To connect React components to the DOM
C. To send data to the server
D. To reduce the size of the bundle

5 What is the only way to change the state inside a Redux store?

A. Dispatching an action
B. Calling the reducer function directly
C. Using the setState method
D. Directly modifying the state object

6 What is an 'Action' in Redux?

A. A connection to the database
B. A method inside a class component
C. A plain JavaScript object that describes what happened
D. A function that returns a component

7 Which property is mandatory in a Redux Action object?

A. payload
B. data
C. type
D. id

8 Which library is commonly used to bind Redux with React?

A. redux-thunk
B. react-router-dom
C. react-redux
D. axios

9 What is the purpose of the <Provider> component in react-redux?

A. To debug the application
B. To make the Redux store available to any nested components
C. To provide API data to components
D. To provide routing capabilities

10 Which prop must be passed to the <Provider> component?

A. store
B. reducer
C. action
D. state

11 What is the correct signature of a Reducer function?

A. (action, state) => newState
B. (state) => newState
C. (state, action) => newState
D. (state, action) => void

12 Why must Reducers be 'pure functions'?

A. To allow side effects like API calls
B. To ensure the UI renders faster
C. To ensure predictable state changes without mutations
D. To allow direct DOM manipulation

13 Which method is used to send an action to the store?

A. store.send()
B. store.push()
C. store.update()
D. store.dispatch()

14 What is an 'Action Creator'?

A. A function that creates the Redux store
B. A function that returns an action object
C. A function that connects components
D. A component that triggers an event

15 In the connect function connect(mapStateToProps, mapDispatchToProps)(MyComponent), what is the purpose of mapStateToProps?

A. To map React props to Redux actions
B. To connect the component to the router
C. To initialize local component state
D. To extract data from the Redux store and pass it as props to the component

16 Which React-Redux hook is synonymous with mapStateToProps?

A. useSelector
B. useStore
C. useReducer
D. useDispatch

17 Which React-Redux hook is used to dispatch actions?

A. useDispatch
B. useSelector
C. useAction
D. useSend

18 What is the typical initial value of the state in a Reducer?

A. Undefined
B. Null
C. Defined via a default parameter
D. The entire database

19 What function is used to combine multiple reducers into a single root reducer?

A. rootReducer
B. mergeReducers
C. joinReducers
D. combineReducers

20 In the Redux flow, what happens immediately after an action is dispatched?

A. The action is sent to the server
B. The view updates
C. The component re-renders
D. The store calls the reducer function

21 What should a reducer return if it receives an action type it does not handle?

A. The current state
B. undefined
C. null
D. An empty object

22 Which statement regarding Redux state immutability is true?

A. You should use state.value = 5 to update values
B. You should use state.push() to add items to an array
C. Redux automatically handles mutation for you
D. You should return a new object/array using spread operators or similar techniques

23 What is the 'payload' in an action?

A. The reducer function
B. Additional data needed to update the state
C. The store object
D. The type of the action

24 Which tool is widely used for debugging Redux applications in the browser?

A. Redux DevTools Extension
B. Node Debugger
C. Chrome Task Manager
D. React Developer Tools

25 What is 'Time Travel Debugging' in Redux?

A. Predicting future states using AI
B. Jumping back and forth between different states recorded by the DevTools
C. Setting breakpoints in the future
D. Running the app in a slower timeframe

26 Which npm command is typically used to build a React app for production?

A. npm run build
B. npm start
C. npm run deploy
D. npm test

27 What is the main advantage of the 'production build' of a React app?

A. It includes hot reloading
B. It runs on a development server
C. It is minified and optimized for performance
D. It includes full error logging

28 Where are the production files typically stored after running the build command?

A. /src
B. /build or /dist
C. /public
D. /node_modules

29 What is a 'store subscriber'?

A. A component that dispatches actions
B. A function that runs whenever the state is updated
C. A library for routing
D. A user who pays for the app

30 When debugging a React app, what does 'Source Map' allow you to do?

A. View the original source code instead of the minified code in the browser
B. Map API endpoints to routes
C. Map components to Redux store
D. Visualise the component tree structure

31 In mapDispatchToProps, if the argument is an object of action creators, what does connect do automatically?

A. It wraps the action creators in a dispatch call
B. It validates the prop types
C. It ignores them
D. It calls the reducers

32 What is the file 'index.js' (or main.jsx) typically used for in a Redux setup?

A. Rendering the App component wrapped in the Provider
B. Storing CSS styles
C. Creating action creators
D. Defining all reducers

33 What is 'Redux Middleware'?

A. A database driver
B. A tool for server-side rendering
C. A CSS framework
D. Software that sits between the dispatching of an action and the moment it reaches the reducer

34 Which of the following is a common middleware used for async actions in Redux?

A. Redux-Router
B. Redux-Sync
C. Redux-DevTools
D. Redux-Thunk

35 If a React app crashes in production, which React feature can display a fallback UI instead of the crash?

A. Error Boundaries
B. Redux Store
C. Service Workers
D. Try-Catch Blocks in render

36 What does process.env.NODE_ENV usually return in a production build?

A. 'test'
B. 'debug'
C. 'development'
D. 'production'

37 When connecting a component, what happens if you pass null instead of mapStateToProps?

A. The application will crash
B. The component will not receive dispatch prop
C. The component will not subscribe to store updates
D. The component receives the whole state

38 What is the purpose of bindActionCreators?

A. To bind this context to components
B. To wrap action creators in dispatch so they can be invoked directly
C. To create the store
D. To combine multiple reducers

39 Which folder in a standard React structure usually contains Redux logic?

A. /assets
B. /public
C. /features
D. /redux or /store

40 Why is using console.log for debugging sometimes inefficient in Redux?

A. It is not supported in Chrome
B. It stops the code execution
C. It clutters the code and doesn't show the state history easily compared to DevTools
D. It cannot print objects

41 In the Flux architecture (which Redux simplifies), flow is always:

A. Random
B. Recursive
C. Bi-directional
D. Unidirectional

42 How can you access the Redux store directly (though not recommended for UI rendering) outside of a component?

A. React.useStore()
B. You cannot access it
C. window.store
D. import store and use store.getState()

43 What is 'Hot Module Replacement' (HMR) helpful for?

A. Encrypting data
B. Replacing the Redux store in production
C. Swapping modules in a running app without a full reload during development
D. Deploying the app to a server

44 Which method allows you to unsubscribe a listener from the store?

A. store.removeListener()
B. store.unsubscribe()
C. store.off()
D. The function returned by store.subscribe()

45 When preparing for deployment, what is 'minification'?

A. Reducing the functionality of the app
B. Compressing images only
C. Removing unused code, shortening variable names, and removing whitespace
D. Converting React to HTML

46 Which hook would you use to perform a side-effect (like data fetching) in a functional component before dispatching an action?

A. useEffect
B. useMemo
C. useReducer
D. useState

47 What is the concept of 'Single Source of Truth' in Redux?

A. The database is the only truth
B. The API is the source of truth
C. The entire state of the application is stored in an object tree within a single store
D. Every component has its own store

48 If you want to deploy your React app to a static host (like GitHub Pages or Netlify), what is the primary requirement?

A. A Node.js backend
B. A Docker container
C. A MySQL database
D. The built static files (HTML, CSS, JS)

49 What is the role of redux-logger?

A. To log every action and the next state to the console
B. To manage login state
C. To log errors to a server
D. To log user login times

50 Why shouldn't you mutate state directly (e.g., state.value++) in Redux?

A. Redux won't detect the change and components won't re-render
B. It makes the app slower
C. It throws a syntax error
D. It deletes the store