Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(hooks): use separate type for server state in useOptimisticAction #134

Merged
merged 3 commits into from
May 18, 2024

Conversation

TheEdoRan
Copy link
Owner

@TheEdoRan TheEdoRan commented May 18, 2024

This PR improves the design of the useOptimisticAction hook. Previously, the optimisticData had to be of the same type of action's return type. This isn't great, because the only job of a Server Action in a optimistic workflow is to mutate the data on the server. The actual state (and type) that matters is the one coming from the parent Server Component, so updateFn's prevState should match that type. The actual result is still available in hooks callbacks and result property returned from the hook, though.

Related issue(s) or discussion(s)

re #127

Copy link

vercel bot commented May 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-safe-action-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 18, 2024 5:22pm
next-safe-action-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 18, 2024 5:22pm

@TheEdoRan TheEdoRan merged commit c38dbe1 into next May 18, 2024
5 checks passed
@TheEdoRan TheEdoRan deleted the rethink-optimistic branch May 18, 2024 17:25
Copy link

🎉 This PR is included in version 7.0.0-next.43 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link

🎉 This PR is included in version 7.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant