Repository navigation
useFormFields should not return dispatchFields
#10733
tyteen4a03
started this conversation in
Feature Requests & Ideas
Replies: 1 comment 1 reply
|
You can return a tuple and type the tuple using the decorator. This seemed like the most logical way to return values and the dispatcher in Payload v2, the that type isn't exported in Payload v3.37.0. Possibly the type is intentionally private and they'll recommend a better approach, or maybe the type will get re-exported as part of #12356, which has an example of this in action except for the TypeScript type error. I also see that at least one person has created their own function as a return value in a tuple in #5167 (comment), which avoids the need to import or recreate the dispatcher type... as long as your you type your function and your function isn't just the dispatcher. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Currently,
useFormFieldscan be used in one of two ways: It can either return fields via a selector, or return adispatchFieldsfunction. You cannot make it return both at the same time via array destructuring.This muddles up the return value and the DX is suboptimal. I think
useFormFieldsshould stop returningdispatchFieldsand instead force the use ofuseFormoruseWatchFormhooks.All reactions