throw or return Error Response from loaders? #14822
Unanswered
alicerocheman
asked this question in
Q&A
Replies: 0 comments 1 reply
-
|
Throwing doesn't affect the return type of the function in TS, so the type of |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
Hi,
I'm currently working on an app with react-router v7 as a framework.
So far, my loaders check the validity of certain routes, and throw a 404 Response if the route makes no sense, or return a redirect.
I've done this because I've seen examples with throwing.
I have not found anything about this in the docs (maybe it should be added there)
I'm wondering whether throwing the 404 response is a good practice, or if it should just be returned.
I've tried both quickly and have not seen a difference on the user end
There is a difference in testing complexity, which would be much simpler if i simply returned responses instead of throwing, which I'm struggling with now, trying to test a complex loader.
Beta Was this translation helpful? Give feedback.
All reactions