17 lines
373 B
TypeScript
17 lines
373 B
TypeScript
import React, { useEffect } from "react";
|
|
import { useLocation } from "react-router-dom";
|
|
|
|
interface IGuardProps {
|
|
children: JSX.Element;
|
|
}
|
|
|
|
export const Guard = (props: IGuardProps) => {
|
|
const location = useLocation();
|
|
|
|
useEffect(() => {
|
|
console.log("location.pathname changed 拦截", location.pathname);
|
|
}, [location.pathname]);
|
|
|
|
return props.children;
|
|
};
|