S
SolidJSβ€’12mo 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
intrnlβ€’12mo ago
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
Alex Lohr
Alex Lohrβ€’12mo 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
intrnlβ€’12mo ago
thanks.
Alex Lohr
Alex Lohrβ€’12mo ago
Happy to help πŸ™‚