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

[React 19] Without extra Generic Type to useActionState hook #32198

Open
PedroGuilhermeFariaDuarte opened this issue Jan 23, 2025 · 0 comments
Open
Labels

Comments

@PedroGuilhermeFariaDuarte

Summary

Hi everyone!

I have a question about the types from the new hook 'useActionState'.

Actually, I'm working on a project and I need some extra types for my action function

A snippet of types from React 19v

Why don't we have an extra Generic Type to return from the action? Does the return really need to be equal to the initial state?

In a real use case, the return from the action can be different from the entry data, such as an error object like:

// INPUT DATA
{
  email: '[email protected]'  
}

// OUTPUT DATA
{
  email: {
    value: '[email protected]'  
    state: {
      error: {
         message: null
      }
    }
  }
}

Reference

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

No branches or pull requests

1 participant