I am passing a user object through the useNavigation object like:
let navigate = useNavigate();
const showUser = (user: UserProp): void => {
navigate('view', { state: user });
}
once i landed to the view component, I am trying to get the value from the location. but getting error.
here is the code :
interface locationProps {
state: { user: UserProp }
}
export default function UserView() {
const { state } = useLocation<locationProps>();
return (
<h1>{state && state.user.name}</h1>
)
}
getting an error as interface locationProps, Expected 0 type arguments, but got 1.