MiroslavPetrik / react-form-action

tRPC like builder for the Next.js & React form actions.
MIT License
19 stars 1 forks source link

formAction creator vs Action Creator #6

Closed tyteen4a03 closed 1 month ago

tyteen4a03 commented 1 month ago

Are there any guidance on when each one should be used?

MiroslavPetrik commented 1 month ago

Hey.

Short answer is that the formAction builder is preferred.

The reasons for it:

the createFormAction has only one benefit, that it will enable you to have standardized responses for the success, error, and invalid cases. This way you don't have to invent your own, which will keep your codebase clean.

The formAction uses the createFormAction internally.