S
SolidJS2y ago
baxuz

Use ErrorBoundary inside a createRoot?

I'm using a pattern where I have a globally accessible resource on a createRoot:
export const [solidStore, updateSolidStore] = createRoot(() => {
const [myResource] = createResource(
{
licenseKey: import.meta.env.VITE_LICENCE_KEY,
},
resourceCreator
);
export const [solidStore, updateSolidStore] = createRoot(() => {
const [myResource] = createResource(
{
licenseKey: import.meta.env.VITE_LICENCE_KEY,
},
resourceCreator
);
However the resourceCreator can error out, crashing the entire application with it. Is there a way to handle this inside a createResource?
2 Replies
fabiospampinato
I guess you can have try..catch block inside resourceCreator if you want this to trigger an ErrorBoundary you'd have to trigger it manually if this ErrorBoundary is not an ancestor of the root
baxuz
baxuzOP2y ago
sadly that's not an option. skipped createResource and switched it to a createSignal + createEffect. Thanks anyway
Want results from more Discord servers?
Add your server