Errors thrown in `loaderDeps` result in a blank page
It seems that the return value of
validateSearch
gets re-merged back into the URL, which wasn’t clear in the docs. This isn’t the behaviour I prefer; I never really want to change what the user wrote.
Therefore, I’m trying to do validation in loaderDeps
, but I found that throw
-ing in loaderDeps
results in a blank white page with nothing being output to the console. The onError
handler does not get invoked. The exception gets completely swallowed. This can’t be the right behaviour?1 Reply
compatible-crimson•5d ago
I think that the main point of
validateSearch
is to use a schema library to valid that the search params match your expectations, this ends up working well since you can do any schema and transformation you want to ensure what the user entered is valid for the application.
Personally, if you want to validate what the user wrote without changing it, you could just as easily use a schema or custom function to validate, and simply throw an error if it is not valid, or return the current search object if it never threw which should do what you need.
someone else may have a better answer to your second issue, but I've never seen something be thrown in the loader deps before, since I would assume that this is somewhat undefined behaviour, you should simply be deriving what state should trigger your loader to re-run, which should never throw. So this case is likely just not handled yet.