openpanel/packages/devtools-ui/src/components/location-change-handler.tsx
Stefan Pejcic 8595a9f4e5 back
2024-05-08 19:58:53 +02:00

19 lines
457 B
TypeScript

import React from "react";
import { useLocation } from "react-router-dom";
import { setLastLocation } from "src/utils/last-location";
export const LocationChangeHandler = () => {
const { pathname } = useLocation();
React.useEffect(() => {
if (
typeof window !== "undefined" &&
typeof localStorage !== "undefined"
) {
setLastLocation(pathname);
}
}, [pathname]);
return null;
};