Reputation: 121
How am i to fix the this any type error?
I tried passing custom type but that didn't work
Upvotes: 3
Views: 733
Reputation: 121
I've been able to resolved it, I checked the node_module for the type and I saw it there. It is the same as the type LocationTypes
@Evren suggested so I restarted my system and it works fine now, didn't know why it wasn't detected without having to restart my system
Upvotes: 2
Reputation: 4410
You can import Location from history. So update would be like this
import { Location } from "history";
const location = useLocation<Location>();
or alternatively you can create types
type LocationTypes = {
pathname: string;
state: any; //Here you can put your data type instead of any
search: string;
hash: string;
key: string;
}
const location = useLocation<LocationTypes>();
Upvotes: 2