【发布时间】:2023-03-20 04:39:02
【问题描述】:
我正在使用 React 中的流进行类型检查。 我在以下情况下遇到错误, 如何处理 this.props.history.push('/home') 如何在道具中定义它? 我已经尝试如下,但它不起作用,
type Prop = { onLoginSuccess: function, setContextDetails: function, callErrorLogger: function, history:string, push:string };
type State = { username: string, password: string, loginsuccess: bool, isLoading: bool };
class Login extends React.Component<Prop, State> {
// here I have some code
this.props.history.push('/home') ;
}
【问题讨论】: