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 694 B
import { useEffect, useRef } from 'react'; import { useLocation } from "./useLocation.js"; /** * 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 const useResetErrorBoundaryOnLocationChange = (resetErrorBoundary) => { const { pathname } = useLocation(); const originalPathname = useRef(pathname); useEffect(() => { if (pathname !== originalPathname.current) { resetErrorBoundary(); } }, [pathname, resetErrorBoundary]); }; //# sourceMappingURL=useResetErrorBoundaryOnLocationChange.js.map