How do I create a complete custom next / react error boundary?

13 Views Asked by At

I am quite new to rext and react.

I have a page with a title and content like a registration form. If something goes wrong on in the form, an alert appears above the form, but in the same grid.

Now I want a generic alert under the page title if something wents wrong which is not caught before. But I want to keep the content how it is.

I found out that theoretically I could use an error boundary. I followed this approache: https://gist.github.com/andywer/800f3f25ce3698e8f8b5f1e79fed5c9c
I created the MyErrorBoundary and the functional-error-boundary.tsx. But I could not trigger it with a throw new Error(..). Also this is only an content or error solution and not error and content solution.

If I could somehow to get the exmaple of the gist running, I could change the code to return the content as well.

What am I doing wrong? Is my idea with theerror boundary wrong?

0

There are 0 best solutions below