Skip to content

Server actions + optimistic UI for the notes form#3

Merged
ThomasHartDev merged 1 commit into
mainfrom
thomas/feat/data-patterns
Jul 20, 2026
Merged

Server actions + optimistic UI for the notes form#3
ThomasHartDev merged 1 commit into
mainfrom
thomas/feat/data-patterns

Conversation

@ThomasHartDev

Copy link
Copy Markdown
Owner

adds a /data-patterns route that mutates a note list through a server action, so there's no client fetch handler at all. the new note shows immediately with useOptimistic and reverts on its own when the write fails, with useActionState holding the confirmed list plus the last error and useFormStatus driving the pending button. pulled the mutation logic into a plain applyAdd function with an injected store so validation, the fail path, and the store-throws path are all tested without the next runtime. theres a checkbox to force a failure so you can watch the optimistic note disappear and the error render. tests cover the reducer folding, trimming/length validation and confirmed state staying put on every failure mode.

@ThomasHartDev
ThomasHartDev merged commit 7b92eb4 into main Jul 20, 2026
1 check passed
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