SolidJSS
SolidJS2y ago
7 replies
sabercoy

Returning Errors and not throwing

I am messing around with actions and useSubmission and I have seen Ryan and the docs mention it is best to return, not throw, Errors
Rather than throwing errors, it is recommended to return them from actions. This helps with the typing of submissions that would be used with useSubmission. This is important when handling progressive enhancement where no JavaScript is present in the client, so that errors can be used declaratively to render the updated page on the server.

I dont understand the "so that errors can be used declaratively to render the updated page on the server" part
Isnt the use of actions in forms and useSubmission always on the client? How are we rendering and updated page on the server? Dont we look at the submission and change the page on the client accordingly? (granted this requires JS)
Was this page helpful?