Skip to content

Reset error boundary when switching layout

Axel Bocciarelli requested to merge reset-boundary into main

Just a bug I noticed while testing !633 (closed): when switching to a layout that causes an error, the error boundary's error state is rendered as expected; however, when switching back to a layout that is known to work, the error remains on the screen and it's difficult to get back to a valid state without refreshing the page.

image

The fix is to implement a simple reset mechanism like they do in react-error-boundary.

I only fixed one error boundary as a demonstration but the others probably cause similar issues. Eventually, I'd recommend using the react-error-boundary package to benefit from this and other features.

Merge request reports