S
SolidJS•2y ago
intrnl

createResource not updating on error

I can't seem to figure out how exactly createResource is supposed to work when the fetcher throws an error, this is the barest reproduction I can do
4 Replies
intrnl
intrnlOP•2y ago
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
Alex Lohr
Alex Lohr•2y ago
The documentation is unfortunately a bit confusing. Resources are lazily evaluated, so they only ever call the fetcher if they are used. However, if they are used and the fetcher rejects with an error, they will throw it against the next boundary, so either set that up or guard the evaluation of the resource with a !resource.error condition.
createEffect(() => {
console.log({ data: profile.error ? {} : profile(), state: profile.state });
});
createEffect(() => {
console.log({ data: profile.error ? {} : profile(), state: profile.state });
});
intrnl
intrnlOP•2y ago
thanks.
Alex Lohr
Alex Lohr•2y ago
Happy to help 🙂
Want results from more Discord servers?
Add your server