[{"id":"reduxbeginner-001","courseId":"redux-beginner","domain":"core-concepts","topic":"Single store for app state","prompt":"A teammate splits an app's global state across three separate stores, one per feature, so each stays small. Under Redux's first principle, which setup is correct?","hint":"Think about how many places the global state is kept under this principle.","explain":"Some designs scatter an app's data across many holders; others keep it all in one structure. Consider what an arrangement with one structure makes easier when you save, inspect or restore an app.","source":"https://redux.js.org/understanding/thinking-in-redux/three-principles","interaction":{"type":"single"},"options":[{"id":"a","text":"Keep all global state in one store, as one object tree","why":"The first principle: the global state of an application is stored in an object tree within a single store."},{"id":"b","text":"Give each feature its own store so each stays small","whyNot":"Several stores split the global state, which breaks the single source of truth principle."},{"id":"c","text":"Keep two stores, one for server data and one for UI state","whyNot":"Two stores still split the global state; the principle wants one object tree inside a single store."},{"id":"d","text":"Keep one store per screen and sync them with dispatched events","whyNot":"Syncing several stores still scatters the state; the principle calls for one store."}],"answer":"a","explanation":"Redux keeps an application's global state in one object tree inside a single store, the single source of truth.","concept":"Redux keeps an application's global state in one object tree inside a single store, the single source of truth.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["One store holds the whole global state as one object tree, which makes an app easier to inspect and persist."]},{"id":"reduxbeginner-002","courseId":"redux-beginner","domain":"core-concepts","topic":"Plain object actions","prompt":"In Redux, an action is a plain JavaScript object that describes what happened.","hint":"Consider whether a message needs a class or special wrapper to count as one.","explain":"A message that reports something happened can be a plain record of data, or an instance of a class that hides behavior. Consider which kind is easier to log, save and compare.","source":"https://redux.js.org/introduction/core-concepts","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","why":"An action is a plain JavaScript object describing what happened, with no class or magic involved."},{"id":"b","text":"False","whyNot":"Actions are plain objects, not class instances, so this claim is not right and the statement holds."}],"answer":"a","explanation":"In Redux, an action is a plain JavaScript object that describes what happened; no class or special wrapper is needed.","concept":"In Redux, an action is a plain JavaScript object that describes what happened; no class or special wrapper is needed.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["An action is just a plain object describing what happened."]},{"id":"reduxbeginner-003","courseId":"redux-beginner","domain":"core-concepts","topic":"Dispatch as the sole path to state changes","prompt":"A call to store.dispatch(action) runs several steps inside the store. Put these steps in the order the store performs them.","hint":"Think about which result must exist before anything can read it.","explain":"A store update is a short synchronous run with a few distinct jobs: computing a fresh value from the old value and a message, making that value visible to readers, and informing anyone watching.","source":"https://redux.js.org/api/store","interaction":{"type":"sort","items":[{"text":"The store calls the reducer with the current state and the action","why":"The update starts synchronously, handing the existing state and the incoming action to the reducer."},{"text":"The reducer's return value becomes the next state","why":"Whatever the reducer returns is adopted as the new state, so it must exist before anyone reads it."},{"text":"getState() returns the new state from now on","why":"Once the new state is set, every later read through getState() sees it."},{"text":"Change listeners are notified immediately","why":"Listeners run last, after the state has been updated, so they can read the new value."}]},"options":[],"answer":"o:abcd","explanation":"dispatch() runs the reducer synchronously with the current state and the action; its return value becomes the new state, which getState() returns, and then listeners are notified.","concept":"dispatch() runs the reducer synchronously with the current state and the action; its return value becomes the new state, which getState() returns, and then listeners are notified.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["dispatch() is the only way to change state: the reducer's return value becomes the new state, then listeners are notified."]},{"id":"reduxbeginner-004","courseId":"redux-beginner","domain":"core-concepts","topic":"Reducer signature","prompt":"You are writing a reducer for a todo list. What does Redux hand the reducer, and what must it hand back?","hint":"Look at what a reducer must know and what it must produce.","explain":"A small function in a bigger program receives what it needs to choose a new value, and hands back a result the program can use. Think about what it must know to build the next version of the data.","source":"https://redux.js.org/introduction/core-concepts","interaction":{"type":"single"},"options":[{"id":"a","text":"The previous state and an action; it returns the next state","why":"A reducer takes the previous state and an action as arguments and returns the next state of the app."},{"id":"b","text":"Only the action; it returns a flag saying whether to re-render","whyNot":"The reducer also needs the previous state, and it returns the next state, not a flag."},{"id":"c","text":"The store and a callback; it returns an unsubscribe function","whyNot":"That describes subscribe(), which registers a listener; reducers are not given the store."},{"id":"d","text":"The previous state and an action; it returns nothing and updates a variable","whyNot":"A reducer must return the next state; it does not update outside values and return nothing."}],"answer":"a","explanation":"A reducer is a function that takes the previous state and an action, and returns the next state of the app.","concept":"A reducer is a function that takes the previous state and an action, and returns the next state of the app.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["A reducer takes the previous state and an action, and returns the next state."]},{"id":"reduxbeginner-005","courseId":"redux-beginner","domain":"core-concepts","topic":"Pure reducers","prompt":"A todo reducer is getting large and bugs keep creeping in. Which TWO of these statements about writing reducers are correct?","hint":"Ask whether the old value is still intact after the function has run.","explain":"Some functions only read their inputs and return a value; others edit what they were given or touch things outside themselves. Consider what happens to the old value afterward, and how predictable the result stays.","source":"https://redux.js.org/understanding/thinking-in-redux/three-principles","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"Return new state objects instead of mutating the previous state","why":"Reducers must produce new objects; editing the old state in place breaks the pure-function rule."},{"id":"b","text":"Split a large reducer into smaller reducers, each managing part of the state tree","why":"As the app grows, reducers can be split so each one manages a specific part of the state tree."},{"id":"c","text":"Edit the old state in place, since the reducer still returns the object at the end","whyNot":"Mutating the previous state is what reducers must avoid, even if an object is returned afterward."},{"id":"d","text":"Call an API inside the reducer, then return the data it fetched","whyNot":"Reducers must have no side effects; fetching belongs in an async action creator, not a reducer."},{"id":"e","text":"Dispatch a follow-up action from the reducer to update a second part of the state","whyNot":"Dispatching inside a reducer throws an error, because reducers must be pure."},{"id":"f","text":"Read Date.now() inside the reducer to stamp each change with a time","whyNot":"A reducer that reads the clock can return different results for the same inputs, so it is not pure."}],"answer":"ab","explanation":"Reducers are pure functions: they return new state objects rather than mutating the previous state, and large reducers can be split into smaller ones by part of the state tree.","concept":"Reducers are pure functions: they return new state objects rather than mutating the previous state, and large reducers can be split into smaller ones by part of the state tree.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Return new objects from a reducer instead of mutating state, and split big reducers by part of the state tree."]}]