0
我有以下方式路线:React路由器如何在路由更改时更改组件中的元素的类名称?
<Route path="" component={Sidebar}>
<Route path="pages/about" component={PageFactory}" />
<Route path="news" component={NewsFactory}" />
</Route>
现在我想添加一个类时的路线更改侧边栏组件。所以,如果路由变成“/ pages/about”,我想要添加“is-open”className到Sidebar组件中的一个元素。如果路由变成“/”,我想远离Sidebar组件中元素的className。
我该如何做到这一点?