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
Suggestion: Adding an ok property to the fetcher object returned by useFetcher. (similar to the Response Web API)
It seems that the common pattern for the Form component is to return error data from the ActionFunction and redirect on a successful POST. Notes about resubmission
If this pattern is not a fit for you application, you can use fetcher.Form with the useFetcher hook. (No redirection)
Because there is no redirection, you have to differentiate between successful and unsuccessful responses in your fetcher.data
Given that we already specify the status for the Response object, I think there is no need for the developer to handle this again on the data payload.
Having fetcher.ok removes the redundancy in the ActionFunction and creates a better DX in my opinion.
Another approach that sticks more to Remix mantra is to have a fetcher.response property with the whole Response object.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Suggestion: Adding an
ok
property to the fetcher object returned byuseFetcher
. (similar to the Response Web API)It seems that the common pattern for the
Form
component is to return error data from theActionFunction
and redirect on a successful POST. Notes about resubmissionIf this pattern is not a fit for you application, you can use
fetcher.Form
with theuseFetcher
hook. (No redirection)Because there is no redirection, you have to differentiate between successful and unsuccessful responses in your
fetcher.data
Given that we already specify the
status
for theResponse
object, I think there is no need for the developer to handle this again on the data payload.Having
fetcher.ok
removes the redundancy in the ActionFunction and creates a better DX in my opinion.Another approach that sticks more to Remix mantra is to have a
fetcher.response
property with the wholeResponse
object.Beta Was this translation helpful? Give feedback.
All reactions