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

Why don’t we have an extra Generic Type to return from the action? Does the re…


This content originally appeared on DEV Community and was authored by Pedro Guilherme

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
      }
    }
  }
}

Reference


This content originally appeared on DEV Community and was authored by Pedro Guilherme


Print Share Comment Cite Upload Translate Updates
APA

Pedro Guilherme | Sciencx (2025-01-21T16:15:46+00:00) Form management. Retrieved from https://www.scien.cx/2025/01/21/form-management/

MLA
" » Form management." Pedro Guilherme | Sciencx - Tuesday January 21, 2025, https://www.scien.cx/2025/01/21/form-management/
HARVARD
Pedro Guilherme | Sciencx Tuesday January 21, 2025 » Form management., viewed ,<https://www.scien.cx/2025/01/21/form-management/>
VANCOUVER
Pedro Guilherme | Sciencx - » Form management. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/01/21/form-management/
CHICAGO
" » Form management." Pedro Guilherme | Sciencx - Accessed . https://www.scien.cx/2025/01/21/form-management/
IEEE
" » Form management." Pedro Guilherme | Sciencx [Online]. Available: https://www.scien.cx/2025/01/21/form-management/. [Accessed: ]
rf:citation
» Form management | Pedro Guilherme | Sciencx | https://www.scien.cx/2025/01/21/form-management/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.