[{"id":"reduxintermediate-001","courseId":"redux-intermediate","domain":"core-concepts","topic":"Reference change detection","prompt":"A counter reducer returns a brand-new object whose fields all hold the same values as before. Does the root state from combineReducers stay the same object?","hint":"Ask what combineReducers compares: the objects themselves, or the values inside them.","explain":"Redux decides whether a value changed by checking whether it is the very same object, not by comparing contents. The check is cheap, so it runs on each slice every time an action is handled.","source":"https://redux.js.org/faq/immutable-data","interaction":{"type":"single"},"options":[{"id":"a","text":"Yes: combineReducers compares the contents of each slice and sees no change","whyNot":"It compares references, not contents, so equal-looking contents in a new object still count as a change."},{"id":"b","text":"No: the slice returned a new reference, so combineReducers sets its changed flag and builds a new root object","why":"A new object fails the shallow equality check, which sets hasChanged to true and produces a new root state."},{"id":"c","text":"Yes: combineReducers only checks the root object and never looks inside the slices","whyNot":"It does check each slice, one key at a time, and that is where the changed flag comes from."},{"id":"d","text":"It depends on whether the new object lists its fields in the same order","whyNot":"Field order does not matter to a reference comparison; only whether the object itself is new."}],"answer":"b","explanation":"combineReducers shallow-checks each slice by reference. A reducer that returns a new object, even one with identical fields, sets hasChanged and produces a new root state object.","concept":"combineReducers shallow-checks each slice by reference. A reducer that returns a new object, even one with identical fields, sets hasChanged and produces a new root state object.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Equal contents in a new object still count as a change to combineReducers."]},{"id":"reduxintermediate-002","courseId":"redux-intermediate","domain":"core-concepts","topic":"Dispatch inside reducers","prompt":"Put these steps of a single store.dispatch(action) call in the order the store performs them.","hint":"Consider which stage produces the value that the next stage needs.","explain":"A dispatch is one synchronous call that runs a fixed pipeline. Some stages compute new data, while others announce the change to outside code, and each stage depends on the output of an earlier one.","source":"https://redux.js.org/api/store","interaction":{"type":"sort","items":[{"text":"The store calls the root reducer with the current state and the action","why":"The reducer is the only step that can compute the next state, so it has to run first, using what the store holds now."},{"text":"The reducer's return value becomes the next state","why":"Nothing new exists until the reducer returns, so the store can only record the return value at this point."},{"text":"getState() starts returning the new state","why":"Once the store holds the next state, later reads through getState() see it."},{"text":"Change listeners are notified","why":"Listeners are called after the new state is in place, so reading it from inside a listener works."}]},"options":[],"answer":"o:abcd","explanation":"dispatch() synchronously calls the reducer with the current state and action, keeps its return value as the next state, returns it from getState(), and then notifies listeners. Reducers may not dispatch.","concept":"dispatch() synchronously calls the reducer with the current state and action, keeps its return value as the next state, returns it from getState(), and then notifies listeners. Reducers may not dispatch.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Listeners run last, so they always read the state that the dispatch produced."]},{"id":"reduxintermediate-003","courseId":"redux-intermediate","domain":"core-concepts","topic":"Subscriber timing","prompt":"A subscribe() listener may call store.dispatch() because Redux calls subscribers only after the root reducer has returned the new state.","hint":"Think about which state a listener can read, and where the reducer sits in the cycle.","explain":"Reducers must be pure: they compute the next state and do nothing else. Listeners run at a different point in each dispatch, and what state they can already read depends on that point.","source":"https://redux.js.org/api/store","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","why":"Subscribers run after the root reducer returns the new state, and the store allows dispatching from them, subject to the caveat about unconditional calls."},{"id":"b","text":"False","whyNot":"The restriction applies to dispatching inside a reducer. Listeners run after the new state exists, so they may dispatch."}],"answer":"a","explanation":"Subscribers run after the root reducer returns the new state, so a listener may dispatch under conditions. Dispatching inside a reducer throws an error instead.","concept":"Subscribers run after the root reducer returns the new state, so a listener may dispatch under conditions. Dispatching inside a reducer throws an error instead.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Listeners may dispatch under conditions; reducers may never dispatch."]},{"id":"reduxintermediate-004","courseId":"redux-intermediate","domain":"core-concepts","topic":"Per-instance sub-app stores","prompt":"A SubApp component creates its store with useState(() => configureStore({ reducer })). BigApp renders three SubApp elements. Which statement about their stores is true?","hint":"Consider what a reducer function contains, and when the initializer runs.","explain":"Work inside a component's first-render initializer runs once per mounted instance. A reducer is only a function that holds no data, so ask where a state tree actually lives.","source":"https://redux.js.org/usage/isolating-redux-sub-apps","interaction":{"type":"single"},"options":[{"id":"a","text":"All three share one store, because they import the same reducer function","whyNot":"A reducer is only a function; each configureStore call makes a new store with its own state tree."},{"id":"b","text":"Each re-render of a SubApp creates a fresh store, so its data resets on every render","whyNot":"The initializer runs only on the first render, so the store survives later re-renders."},{"id":"c","text":"Each SubApp instance gets its own store, created once on its first render, and the instances cannot see each other's data","why":"The useState initializer runs only on the first render, so each instance keeps one store for its lifetime, and the stores share nothing."},{"id":"d","text":"The stores only work if a single Provider wraps BigApp at the root","whyNot":"Each sub-app wraps its own Provider, hiding Redux inside the component, so no root Provider is needed."}],"answer":"c","explanation":"A useState initializer runs only on the first render, so each SubApp creates exactly one store. A reducer function holds no data, and each configureStore call builds an independent store.","concept":"A useState initializer runs only on the first render, so each SubApp creates exactly one store. A reducer function holds no data, and each configureStore call builds an independent store.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Each sub-app store lives with its component instance and shares nothing by default."]},{"id":"reduxintermediate-005","courseId":"redux-intermediate","domain":"core-concepts","topic":"Normalized state for rendering","prompt":"A React 18 app's thunk dispatches three actions back to back, in the same tick, with no batch() call. Which TWO statements are true?","hint":"Separate what the store does after each action from when React redraws the screen.","explain":"The store reports each handled action to its subscribers, but React decides separately when to redraw. Count the store's work and the screen's redraws on their own terms.","source":"https://redux.js.org/faq/performance","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"React 18 renders the component three times, once per dispatch","whyNot":"React 18 batches state updates in the same tick into a single render pass, even when they come from Redux dispatches."},{"id":"b","text":"Subscribers are notified once for each of the three dispatches","why":"Redux notifies subscribers after every dispatched action that reaches the reducers, so three dispatches mean three notifications."},{"id":"c","text":"Subscribers are notified only once, after the thunk returns","whyNot":"Notifications follow each action, not one call at the end; the page says subscribers and selectors run once per action."},{"id":"d","text":"React 18 batches the three updates into one render pass","why":"React 18 and later batch updates in the same event loop tick, including those triggered by Redux dispatches in thunks."},{"id":"e","text":"Without batch(), React drops the second and third actions","whyNot":"Nothing is dropped: every action reaches the reducers, and React only batches the rendering."},{"id":"f","text":"Selectors run once per render, so the store does no selector work per action","whyNot":"The page says selectors run once per action, even though React renders only once."}],"answer":"bd","explanation":"Redux notifies subscribers and runs selectors after each dispatched action. React 18 batches same-tick updates into one render pass, so the screen updates once.","concept":"Redux notifies subscribers and runs selectors after each dispatched action. React 18 batches same-tick updates into one render pass, so the screen updates once.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Store work follows each dispatch; React rendering follows the batched updates."]}]