pankod/refine

View on GitHub
packages/devtools-ui/src/components/location-change-handler.tsx

Summary

Maintainability
A
0 mins
Test Coverage
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;
};