DEV Community

Cover image for Form management
Pedro Guilherme
Pedro Guilherme

Posted on

Form management

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: 'user@email.com'  
}

// OUTPUT DATA
{
  email: {
    value: 'user@email.com'  
    state: {
      error: {
         message: null
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Reference

Top comments (0)