我正在尝试使用React Router将props从我的app.jsx传递到我的路由组件之一,但是出现以下错误
TypeError:无法读取未定义的属性“ acc”
这是我的app.jsx中的代码:
<Route exact path='/FileUpload' acc={this.state.account} ethAdd={this.state.ethAddress} component={FileUpload} />
Run Code Online (Sandbox Code Playgroud)
路由中的组件中的代码导致:
constructor(props) {
super(props);
this.setState({
account: this.props.route.acc,
ethAddress: this.props.route.ethAdd
})
}
Run Code Online (Sandbox Code Playgroud)
我从这里阅读其他解决方案并不能真正理解在响应路由器中传递道具的工作原理,有人可以帮助我理解我需要做什么吗?