属性'背景'在类型上不存在,未知' ReactJS/usehistory()
我在类型的'unknown.ts(2339)上获取此错误属性'背景',当我尝试使用此代码时,
const location = useLocation();
const background = location.state && location.state.background;
我从React-Router-dom导入了所有所需的函数
import {
Redirect,
Route,
RouteComponentProps,
Switch,
useLocation,
withRouter,
} from "react-router-dom";
,我正在使用类Component如果确实很重要。
如果您能给我一些技巧,我将非常感激。
I'm getting this error Property 'background' does not exist on type 'unknown'.ts(2339), when I try to use this code
const location = useLocation();
const background = location.state && location.state.background;
I imported all of the needed functions from react-router-dom
import {
Redirect,
Route,
RouteComponentProps,
Switch,
useLocation,
withRouter,
} from "react-router-dom";
I'm using class component if it does matter.
I will be very grateful if you could give me some tips.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)