Is it possible to show <Errorboundary> as toast/pop up?

Or does it always need to show either the error component/view or the non error view?
6 Replies
Alex Lohr
Alex Lohr3mo ago
The fallback prop can contain anything that is rendered on error - it can also be a toast. However, the default layout cannot be rendered, as it threw an error while doing so, so we do not get any output from it. If you want to show errors as toasts over the layout, you need to use catchError and resource.error to avoid errors being thrown at the boundary.
Massukka
MassukkaOP3mo ago
I will look into those
gsoutz
gsoutz3mo ago
You can just have the error boundary inside your main layout, so main layout always renders.
Massukka
MassukkaOP3mo ago
I don't think I can get props.children of app.tsx to render simultaneously with that method. Is there some example code with catcherror somewhere?
Madaxen86
Madaxen863mo ago
Well if you can just catch the error you can use it in any way you want. ErrorBoundary is just for uncaught errors. Eg. … = createAsync(()=>getSomeData().catch(err => showToast(err)) Should work.
Alex Lohr
Alex Lohr3mo ago
That's not the whole story. Error boundaries are meant to encapsulate components that do not work. Imagine a video device selector when the error is "not permitted". At the app level, they work as a catch-all.
Want results from more Discord servers?
Add your server