Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
What is Redux primarily used for in a React application?
Not quite. Try another option.
Answer: State management
Redux is a predictable state container for JavaScript apps, primarily used for managing application state in a central store.
Question 2 of 50
Which of the following is NOT one of the three fundamental principles of Redux?
Not quite. Try another option.
Answer: State is distributed across components
Redux operates on a single source of truth (one store), whereas distributing state across components describes local component state or Context API usage.
Question 3 of 50
In Redux, what is the 'Store'?
Not quite. Try another option.
Answer: An object that holds the application state
The Store is the object that brings actions and reducers together and holds the application state.
Question 4 of 50
What is the purpose of a 'Reducer' in Redux?
Not quite. Try another option.
Answer: To specify how the application's state changes in response to actions
Reducers are pure functions that take the previous state and an action, and return the next state.
Question 5 of 50
What is the only way to change the state inside a Redux store?
Not quite. Try another option.
Answer: Dispatching an action
According to Redux principles, the state is read-only. The only way to change it is to emit (dispatch) an action describing what happened.
Question 6 of 50
What is an 'Action' in Redux?
Not quite. Try another option.
Answer: A plain JavaScript object that describes what happened
An action is a plain JavaScript object that must have a 'type' property and acts as a payload of information to the store.
Question 7 of 50
Which property is mandatory in a Redux Action object?
Not quite. Try another option.
Answer: type
Actions must have a type property that indicates the type of action being performed.
Question 8 of 50
Which library is commonly used to bind Redux with React?
Not quite. Try another option.
Answer: react-redux
React Redux is the official React UI binding library for Redux.
Question 9 of 50
What is the purpose of the <Provider> component in react-redux?
Not quite. Try another option.
Answer: To make the Redux store available to any nested components
The <Provider> component wraps the React app and makes the Redux store available to any nested component that needs to access the Redux store.
Question 10 of 50
Which prop must be passed to the <Provider> component?
Not quite. Try another option.
Answer: store
The <Provider> component requires the Redux store to be passed as a prop.
Question 11 of 50
What is the correct signature of a Reducer function?
Not quite. Try another option.
Answer: (state, action) => newState
A reducer is a pure function that takes the current state and an action, and returns the new state.
Question 12 of 50
Why must Reducers be 'pure functions'?
Not quite. Try another option.
Answer: To ensure predictable state changes without mutations
Pure functions do not modify their arguments and have no side effects, which is crucial for Redux's predictability and features like time-travel debugging.
Question 13 of 50
Which method is used to send an action to the store?
Not quite. Try another option.
Answer: store.dispatch()
dispatch(action) is the method used to trigger a state change.
Question 14 of 50
What is an 'Action Creator'?
Not quite. Try another option.
Answer: A function that returns an action object
Action creators are simply functions that create and return an action object to avoid writing the object manually every time.
Question 15 of 50
In the connect function connect(mapStateToProps, mapDispatchToProps)(MyComponent), what is the purpose of mapStateToProps?
Not quite. Try another option.
Answer: To extract data from the Redux store and pass it as props to the component
mapStateToProps allows a component to subscribe to Redux store updates and select the part of the data it needs.
Question 16 of 50
Which React-Redux hook is synonymous with mapStateToProps?
Not quite. Try another option.
Answer: useSelector
useSelector is a hook that allows you to extract data from the Redux store state, similar to mapStateToProps.
Question 17 of 50
Which React-Redux hook is used to dispatch actions?
Not quite. Try another option.
Answer: useDispatch
useDispatch returns a reference to the dispatch function from the Redux store.
Question 18 of 50
What is the typical initial value of the state in a Reducer?
Not quite. Try another option.
Answer: Defined via a default parameter
Reducers usually define an initialState variable and set it as the default value for the state argument (e.g., state = initialState).
Question 19 of 50
What function is used to combine multiple reducers into a single root reducer?
Not quite. Try another option.
Answer: combineReducers
combineReducers is a helper function from Redux that turns an object whose values are different reducing functions into a single reducing function.
Question 20 of 50
In the Redux flow, what happens immediately after an action is dispatched?
Not quite. Try another option.
Answer: The store calls the reducer function
Once an action is dispatched, the store calls the reducer function with the current state and the dispatched action.
Question 21 of 50
What should a reducer return if it receives an action type it does not handle?
Not quite. Try another option.
Answer: The current state
If a reducer doesn't recognize the action type, it must return the current state unchanged.
Question 22 of 50
Which statement regarding Redux state immutability is true?
Not quite. Try another option.
Answer: You should return a new object/array using spread operators or similar techniques
Redux requires state updates to be immutable. You cannot modify the existing state object; you must return a new copy with the changes.
Question 23 of 50
What is the 'payload' in an action?
Not quite. Try another option.
Answer: Additional data needed to update the state
The payload property carries the data necessary to perform the state update (e.g., the ID of an item to delete or the new user data to add).
Question 24 of 50
Which tool is widely used for debugging Redux applications in the browser?
Not quite. Try another option.
Answer: Redux DevTools Extension
Redux DevTools Extension allows developers to inspect every state and action payload, and perform time-travel debugging.
Question 25 of 50
What is 'Time Travel Debugging' in Redux?
Not quite. Try another option.
Answer: Jumping back and forth between different states recorded by the DevTools
Time travel debugging allows you to revert the app to a previous state by cancelling actions or replaying them to see how the state evolved.
Question 26 of 50
Which npm command is typically used to build a React app for production?
Not quite. Try another option.
Answer: npm run build
npm run build executes the build script (usually created by Create React App) to bundle the app for production.
Question 27 of 50
What is the main advantage of the 'production build' of a React app?
Not quite. Try another option.
Answer: It is minified and optimized for performance
A production build bundles files, minifies code (removes whitespace/comments), and optimizes assets to ensure the app loads fast for users.
Question 28 of 50
Where are the production files typically stored after running the build command?
Not quite. Try another option.
Answer: /build or /dist
Create React App creates a build folder (sometimes dist in other tools like Vite) containing the static files ready for deployment.
Question 29 of 50
What is a 'store subscriber'?
Not quite. Try another option.
Answer: A function that runs whenever the state is updated
store.subscribe(listener) allows you to register a callback listener that triggers whenever an action is dispatched and the state tree might have changed.
Question 30 of 50
When debugging a React app, what does 'Source Map' allow you to do?
Not quite. Try another option.
Answer: View the original source code instead of the minified code in the browser
Source maps map the compressed/minified code back to the original source code, allowing you to debug the actual code you wrote.
Question 31 of 50
In mapDispatchToProps, if the argument is an object of action creators, what does connect do automatically?
Not quite. Try another option.
Answer: It wraps the action creators in a dispatch call
If mapDispatchToProps is an object, connect wraps each function with dispatch so you can call them directly as props.
Question 32 of 50
What is the file 'index.js' (or main.jsx) typically used for in a Redux setup?
Not quite. Try another option.
Answer: Rendering the App component wrapped in the Provider
The entry point file is typically where the Redux Store is created and passed to the <Provider>, which wraps the root <App />.
Question 33 of 50
What is 'Redux Middleware'?
Not quite. Try another option.
Answer: Software that sits between the dispatching of an action and the moment it reaches the reducer
Middleware provides a third-party extension point between dispatching an action and the moment it reaches the reducer (e.g., for logging or async requests).
Question 34 of 50
Which of the following is a common middleware used for async actions in Redux?
Not quite. Try another option.
Answer: Redux-Thunk
Redux Thunk is a standard middleware that allows you to write action creators that return a function instead of an action, enabling async logic.
Question 35 of 50
If a React app crashes in production, which React feature can display a fallback UI instead of the crash?
Not quite. Try another option.
Answer: Error Boundaries
Error boundaries are React components that catch JavaScript errors anywhere in their child component tree and display a fallback UI.
Question 36 of 50
What does process.env.NODE_ENV usually return in a production build?
Not quite. Try another option.
Answer: 'production'
Build tools set NODE_ENV to 'production' during the build process to disable development-specific warnings and enable optimizations.
Question 37 of 50
When connecting a component, what happens if you pass null instead of mapStateToProps?
Not quite. Try another option.
Answer: The component will not subscribe to store updates
Passing null tells connect that this component does not need to listen to the store state, optimizing performance.
Question 38 of 50
What is the purpose of bindActionCreators?
Not quite. Try another option.
Answer: To wrap action creators in dispatch so they can be invoked directly
bindActionCreators turns an object whose values are action creators, into an object with the same keys, but with every action creator wrapped into a dispatch call.
Question 39 of 50
Which folder in a standard React structure usually contains Redux logic?
Not quite. Try another option.
Answer: /redux or /store
While structure varies (e.g., feature folders), a dedicated /redux, /store, or /actions & /reducers folder is standard convention.
Question 40 of 50
Why is using console.log for debugging sometimes inefficient in Redux?
Not quite. Try another option.
Answer: It clutters the code and doesn't show the state history easily compared to DevTools
Redux DevTools provides a structured history, state diffs, and time travel, which is far superior to manual logging.
Question 41 of 50
In the Flux architecture (which Redux simplifies), flow is always:
Not quite. Try another option.
Answer: Unidirectional
Redux follows strict unidirectional data flow: Action -> Dispatch -> Reducer -> Store -> View.
Question 42 of 50
How can you access the Redux store directly (though not recommended for UI rendering) outside of a component?
Not quite. Try another option.
Answer: import store and use store.getState()
You can import the created store object into other files and call store.getState() to read the current state snapshot.
Question 43 of 50
What is 'Hot Module Replacement' (HMR) helpful for?
Not quite. Try another option.
Answer: Swapping modules in a running app without a full reload during development
HMR allows developers to see changes in CSS or JS immediately without losing the application state (like the Redux store state).
Question 44 of 50
Which method allows you to unsubscribe a listener from the store?
Not quite. Try another option.
Answer: The function returned by store.subscribe()
store.subscribe returns a function that, when called, unregisters the listener.
Question 45 of 50
When preparing for deployment, what is 'minification'?
Not quite. Try another option.
Answer: Removing unused code, shortening variable names, and removing whitespace
Minification reduces file size to speed up download times for the user.
Question 46 of 50
Which hook would you use to perform a side-effect (like data fetching) in a functional component before dispatching an action?
Not quite. Try another option.
Answer: useEffect
useEffect is used for side effects. You would fetch data inside useEffect and then dispatch a Redux action with the result.
Question 47 of 50
What is the concept of 'Single Source of Truth' in Redux?
Not quite. Try another option.
Answer: The entire state of the application is stored in an object tree within a single store
This principle simplifies debugging and inspecting the application since all state resides in one place.
Question 48 of 50
If you want to deploy your React app to a static host (like GitHub Pages or Netlify), what is the primary requirement?
Not quite. Try another option.
Answer: The built static files (HTML, CSS, JS)
Static hosts serve pre-built HTML/CSS/JS files generated by npm run build; they do not execute server-side code.
Question 49 of 50
What is the role of redux-logger?
Not quite. Try another option.
Answer: To log every action and the next state to the console
redux-logger is a middleware that logs dispatched actions and the resulting state change to the console for debugging.
Question 50 of 50
Why shouldn't you mutate state directly (e.g., state.value++) in Redux?
Not quite. Try another option.
Answer: Redux won't detect the change and components won't re-render
Redux uses shallow equality checking. If the object reference doesn't change (which happens in mutation), Redux assumes state hasn't changed and won't update the UI.
That's unit 6
Answer a few questions and your score shows up here.
Nearly through. Did unit 6 of INT252 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 6 of INT252 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.