{error.message ?? JSON.stringify(error)}
+ > + ); + } + + const { children } = this.props; + return children; + } +} + +export const ErrorBoundary = ({ children }: { children: React.ReactNode }) => { + const [key, setKey] = useState(0); + const { pathname } = useLocation(); + const previousPathnameRef = useRef(pathname); + const [trackPathChange, setTrackPathChange] = useState(false); + + useEffect(() => { + if (trackPathChange && previousPathnameRef.current !== pathname) { + previousPathnameRef.current = pathname; + setKey((currentKey) => (currentKey + 1) % 999999); + setTrackPathChange(false); + } + }, [pathname, previousPathnameRef.current, trackPathChange]); + + return ( +