[英]react router 6.4.3 typescript - useLocation any type error
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>();
I've been able to resolved it, I checked the node_module for the type and I saw it there.我已经能够解决它,我检查了 node_module 的类型,我在那里看到了它。 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它与
type LocationTypes
@Evren建议的类型相同,所以我重新启动了我的系统并且它现在工作正常,不知道为什么它没有被检测到而无需重新启动我的系统
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.