Skip to content

feat: Add client state patterns for context vs store#4

Merged
ThomasHartDev merged 1 commit into
mainfrom
thomas/feat/state-management
Jul 23, 2026
Merged

feat: Add client state patterns for context vs store#4
ThomasHartDev merged 1 commit into
mainfrom
thomas/feat/state-management

Conversation

@ThomasHartDev

Copy link
Copy Markdown
Owner

Same pure cart reducer runs in two hosts on /state-management so you can feel the re-render difference. Context + useReducer (with state and dispatch split) is fine for tree-scoped UI, but any field change notifies every state consumer. The external store uses useSyncExternalStore plus selectors, so typing the note leaves the badge and total alone.

No-op actions return the prior state reference so the store skips notify. When most leaves only need a thin slice, or updates get chatty, that selector path is the better default for now.

@ThomasHartDev
ThomasHartDev merged commit 315ed0c into main Jul 23, 2026
1 check passed
@ThomasHartDev
ThomasHartDev deleted the thomas/feat/state-management branch July 23, 2026 17:37
Comment thread src/state/create-store.ts
Comment thread src/state/cart-context.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant