You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently formAction returns Promise<Response> which is usually okay, but makes my life complicated when I need to infer the shape of the result for useFetcher.
Yes, I know I can achieve what I want by using type utils from domain-functions, but how cool would it be if that happened automagically =)
// this is when we have errors you have access to errors and values (internally used by HookForm)if(actionData?.errors){actionData.errors;actionData.values;// if errors are null we have access to response from action}elseif(actionData?.data){actionData.data.abc;// @ts-expect-error this should trigger erroractionData.data.nonExist;}
Yes, spend some time thinking on that piece already...
First I was considering changing the return type to be dependent on successPath value, but we also need to account for error case, so we'd need a type guard in the handler anyways...
As it seems there's must be some app code to properly type the result anyways -- no need to touch the library code then.
Currently formAction returns
Promise<Response>
which is usually okay, but makes my life complicated when I need to infer the shape of the result foruseFetcher
.Yes, I know I can achieve what I want by using type utils from
domain-functions
, but how cool would it be if that happened automagically =)Form action behavior:
Normal action behavior:
The text was updated successfully, but these errors were encountered: