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. Routing
C. Database management
D. Server-side rendering

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

A. State is distributed across components
B. Changes are made with pure functions
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 component that renders UI
C. An object that holds the application state
D. A middleware for API calls

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

A. To connect React components to the DOM
B. To specify how the application's state changes in response to actions
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 method inside a class component
B. A plain JavaScript object that describes what happened
C. A function that returns a component
D. A connection to the database

7 Which property is mandatory in a Redux Action object?

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

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

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

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

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

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

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

11 What is the correct signature of a Reducer function?

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

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 direct DOM manipulation
D. To allow side effects like API calls

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

A. store.push()
B. store.dispatch()
C. store.send()
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 extract data from the Redux store and pass it as props to the component
B. To connect the component to the router
C. To map React props to Redux actions
D. To initialize local component state

16 Which React-Redux hook is synonymous with mapStateToProps?

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

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. The entire database
B. Defined via a default parameter
C. Undefined
D. Null

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

A. joinReducers
B. rootReducer
C. mergeReducers
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 component re-renders
C. The view updates
D. The store calls the reducer function

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.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 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. Node Debugger
B. Chrome Task Manager
C. React Developer Tools
D. Redux DevTools Extension

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. Running the app in a slower timeframe
D. Predicting future states using AI

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

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

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

A. It is minified and optimized for performance
B. It includes full error logging
C. It includes hot reloading
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. /node_modules
D. /build or /dist

29 What is a 'store subscriber'?

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

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

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

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

A. It validates the prop types
B. It calls the reducers
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. Creating action creators
B. Rendering the App component wrapped in the Provider
C. Defining all reducers
D. Storing CSS styles

33 What is 'Redux Middleware'?

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

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

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

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

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

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

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

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

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

38 What is the purpose of bindActionCreators?

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

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 clutters the code and doesn't show the state history easily compared to DevTools
B. It stops the code execution
C. It is not supported in Chrome
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. import store and use store.getState()
C. You cannot access it
D. window.store

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. Encrypting data
D. Replacing the Redux store in production

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

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

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

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

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

A. The database is the only truth
B. Every component has its own store
C. The API is the source of truth
D. The entire state of the application is stored in an object tree within a single 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 MySQL database
B. The built static files (HTML, CSS, JS)
C. A Node.js backend
D. A Docker container

49 What is the role of redux-logger?

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

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

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