我在react路由组件中传递一个prop,如下所示:
<Route exact
path='/'
component={HomePage}
display_notification={this.display_notification.bind(this)}
/>但是当我打印HomePage的道具时,我找不到display_notification。
请帮帮忙。
我使用的是react-router-v4
发布于 2017-07-26 02:24:51
Route不会为你重组道具,它只传递与内部位置相关的道具。您需要使用render={}接口- https://reacttraining.com/react-router/web/api/Route/render-func
所以就像这样
<Route exact
path='/'
render={() => <HomePage display_notification={this.display_notification} />} />https://stackoverflow.com/questions/45310897
复制相似问题