submisison.error logs to console but isn't rendered on the page
In this example I see
submission.error
logs to the console but it doesn't render on the page?
8 Replies
I can also put the
console.log
in the return and it prints the error
Typescript, still somewhat new to me, helped me out. I just had to deal with the types returned properly.get it to show error message like this:
https://docs.solidjs.com/solid-router/reference/data-apis/use-submission#error-handling
useSubmission - Solid Router Docs
Documentation for SolidJS, the signals-powered UI framework
apparently error is type as any so there's no lsp completion:
That's a general JS issue because in JS we can throw anything.
We could even
throw new Date()
😵💫
To check if it was throw new Error(...
you can
if (sub.error instanceOf Error)
Then it is typed.throw new Date is diabolical lol, but yeah, another reason to return error as value.
console.log
is calling .toString()
on the error. That is why the message prints in createEffect(() => console.log(sub.error))
, but not in the JSX when you do sub.error
without the .message
.This is JS at its finest 😭
After some reading
console.log
does a bit more than call toString
, which it does some times, but saying it does catches the general idea.