new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Redux Toolkit · API · all subjects

immer integration

6 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

State must be serializable to JSON

Non-serializable values such as Date objects, Set, Map, or functions in state break Redux DevTools, time-travel debugging, persistence, and equality assumptions in subtle ways. Store only JSON-serializable primitives, arrays, and plain objects.

Replace Date objects with ISO string timestamps

Instead of lastSeen: new Date(), use lastSeenIso: new Date().toISOString(). ISO strings are serializable and work with DevTools and persistence.

Replace Set with array for serializable collections

Instead of pendingIds: new Set<string>(), use pendingIds: [] as string[]. Arrays are serializable and maintain Redux store integrity.

Immer integration in Redux Toolkit

Redux Toolkit integrates Immer through createReducer and createSlice. Immer's createNextState (aliased as createNextState in exports), Draft, current, original, freeze, and isDraft are re-exported from redux-toolkit. Case reducers receive Draft<S> state allowing immutable-style mutations that Immer converts to immutable updates.

Immer mutation syntax only valid inside Immer-backed reducers

Mutation syntax like state.push() or state.field = value is only safe inside Immer-backed reducer contexts such as createSlice and createReducer. Mutating arrays and objects outside these contexts is incorrect and breaks immutability. Write mutation logic directly inside slice reducer functions instead of copying data manually.

Redux Toolkit eliminates accidental mutations which are the #1 cause of Redux bugs

Redux Toolkit was specifically designed to eliminate accidental mutations, which have always been the number one cause of Redux bugs. The Immer library integration in createSlice enables writing immutable updates using mutating syntax, preventing mutation mistakes.

Give your agent this brain