Unit 6 - Practice Quiz

INT252

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

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

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

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

3 In Redux, what is the 'Store'?

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

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

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

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

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

6 What is an 'Action' in Redux?

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

7 Which property is mandatory in a Redux Action object?

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

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

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

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

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

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

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

11 What is the correct signature of a Reducer function?

A. (state, action) => newState
B. (action, state) => newState
C. (state) => 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.dispatch()
C. store.push()
D. store.update()

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 extract data from the Redux store and pass it as props to the component
C. To connect the component to the router
D. To initialize local component state

16 Which React-Redux hook is synonymous with mapStateToProps?

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

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

A. useAction
B. useDispatch
C. useSelector
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. mergeReducers
B. combineReducers
C. rootReducer
D. joinReducers

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

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

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

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

22 Which statement regarding Redux state immutability is true?

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

23 What is the 'payload' in an action?

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

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

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

25 What is 'Time Travel Debugging' in Redux?

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

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

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

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

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

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

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

29 What is a 'store subscriber'?

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

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

A. Map components to Redux store
B. View the original source code instead of the minified code in the browser
C. Map API endpoints to routes
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 calls the reducers
B. It validates the prop types
C. It wraps the action creators in a dispatch call
D. It ignores them

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

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

33 What is 'Redux Middleware'?

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

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

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

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

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

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

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

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

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

38 What is the purpose of bindActionCreators?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

A. Reducing the functionality of the app
B. Removing unused code, shortening variable names, and removing whitespace
C. Compressing images only
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. useReducer
B. useState
C. useEffect
D. useMemo

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

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

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 MySQL database
C. The built static files (HTML, CSS, JS)
D. A Docker container

49 What is the role of redux-logger?

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

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

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