【发布时间】:2019-06-01 23:58:59
【问题描述】:
我正在开发一个 ReactJS 项目。我在主页“索引组件”中有3个组件如下,
导航- 精选- 页脚
我的导航组件有 2 个链接到 2 个不同的组件。 我的Switch如下,
<Switch>
<Route path="/home" component={props => <Index {...props} />} />
<Route path="/register" component={Register} />
<Route path="/login" component={Login} />
<Route path="/cart" component={Cart} />
<Redirect from="/" to="home" />
</Switch>
我的索引组件也如下,
<React.Fragment>
<Search />
<Nav history={history} />
{this.homePageComponents()}
<Route
path="/home/bedding"
component={props => (
<Bedding beddingProducts={this.beddingProducts()} {...props} />
)}
/>
<Route
path="/home/bath"
component={props => (
<Bath bathProducts={this.bathProducts()} {...props} />
)}
/>
<Route path="/home/search" component={Search} />
</React.Fragment>
我正在尝试将 Nav 组件渲染到 Bath 和 Bedding 产品,但每当我导入它并在那里使用它时,它都会给我一个错误,说 this.props.history.replace 未定义。 这是项目的链接。 https://github.com/MaxOffline/beetle
【问题讨论】:
-
请提供错误。
-
这是说 this.props.history.replace 是未定义的
标签: javascript reactjs