如何使用React Router 4在路由更改时呈现特定组件?

时间:2017-09-27 05:25:48

标签: react-router

我有以下路线,

<Route exact path ='/' component={Posts} />
<Route exact path ='/:category' component={Posts} />
<Route exact path ='/new' component={NewPost} />

问题是当我转到/new路线时,Post组件也会与NewPost组件一起呈现。如何避免?

1 个答案:

答案 0 :(得分:0)

我必须在Component中包装路由。它奏效了。

FLAG_ACTIVITY_CLEAR_TASK