【发布时间】:2021-08-22 02:04:55
【问题描述】:
导航到新路线后,我正在尝试传递状态数据,打字稿告诉我
类型 'State' 上不存在属性 'email'。"
父功能组件:
navigate('/check-mail', { state: { email: "hello, I'm an email" } });
子功能组件:
const SentPasswordResetInstructions = () => {
const location = useLocation();
let { email } = location.state;
}
我尝试过创建这样的界面:
interface propState { email : string }
然后使用
useLocation<propState>();
但是,这会引发其他错误。我该如何解决这个问题??
【问题讨论】:
标签: reactjs typescript react-router