UNPKG

ra-core

Version:

Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React

18 lines 701 B
import { useEffect, useRef } from 'react'; import { useLocation } from 'react-router'; /** * A hook to use inside the component passed to FallbackComponent * of react-error-boundary. It resets the error boundary state whenever * the location changes * @param {Function} resetErrorBoundary */ export var useResetErrorBoundaryOnLocationChange = function (resetErrorBoundary) { var pathname = useLocation().pathname; var originalPathname = useRef(pathname); useEffect(function () { if (pathname !== originalPathname.current) { resetErrorBoundary(); } }, [pathname, resetErrorBoundary]); }; //# sourceMappingURL=useResetErrorBoundaryOnLocationChange.js.map