useFormFields
should not return dispatchFields
#10733
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. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently,
useFormFields
can be used in one of two ways: It can either return fields via a selector, or return adispatchFields
function. 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
useFormFields
should stop returningdispatchFields
and instead force the use ofuseForm
oruseWatchForm
hooks.Beta Was this translation helpful? Give feedback.
All reactions