Unit 6 - Practice Quiz

INT252 50 Questions
0 Correct 0 Wrong 50 Left
0/50

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

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

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

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

3 In Redux, what is the 'Store'?

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

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 connect React components to the DOM
D. To specify how the application's state changes in response to actions

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 plain JavaScript object that describes what happened
C. A method inside a class component
D. A function that returns a component

7 Which property is mandatory in a Redux Action object?

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

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

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

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 routing capabilities
D. To provide API data to components

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

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

11 What is the correct signature of a Reducer function?

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

12 Why must Reducers be 'pure functions'?

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

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

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

14 What is an 'Action Creator'?

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

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

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

16 Which React-Redux hook is synonymous with mapStateToProps?

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

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

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

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

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

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

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

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

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

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

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

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. Additional data needed to update the state
B. The type of the action
C. The store object
D. The reducer function

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

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

25 What is 'Time Travel Debugging' in Redux?

A. Setting breakpoints in the future
B. Predicting future states using AI
C. Jumping back and forth between different states recorded by the DevTools
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 run build
C. npm test
D. npm run deploy

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

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

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

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

29 What is a 'store subscriber'?

A. A component that dispatches actions
B. A library for routing
C. A function that runs whenever the state is updated
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 components to Redux store
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 wraps the action creators in a dispatch call
B. It validates the prop types
C. It calls the reducers
D. It ignores them

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

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

33 What is 'Redux Middleware'?

A. A tool for server-side rendering
B. A CSS framework
C. A database driver
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. Redux Store
B. Error Boundaries
C. Try-Catch Blocks in render
D. Service Workers

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

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

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 receives the whole state
D. The component will not subscribe to store updates

38 What is the purpose of bindActionCreators?

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

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

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

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

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

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

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

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

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

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

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

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. Converting React to HTML
C. Removing unused code, shortening variable names, and removing whitespace
D. Compressing images only

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. useMemo
C. useEffect
D. useState

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

A. The entire state of the application is stored in an object tree within a single store
B. The database is the only truth
C. The API is the source of truth
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 log user login times
C. To manage login state
D. To log errors to a server

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

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