You can create a particular type or interface to describe your location state and then use it when calling a useLocation
hook:
import React from "react";
import { useLocation } from "react-router-dom";
interface LocationState {
from: {
pathname: string;
};
}
const AuthLayer: React.FC = (props) => {
const location = useLocation<LocationState>();
const { from } = location.state || { from: { pathname: "https://stackoverflow.com/" } };
return <p></p>;
};
export default AuthLayer;