如何将className添加到所有子路由?

时间:2015-12-15 22:26:20

标签: react-router

我的一个Route在其render()中有一个包含它的组件:

<div>
  <Nav/>
      {this.props.children}
  <Footer/>
</div>

如何将通过它呈现的所有组件作为子类提供给className?

我试过这个:

<div>
  <Nav/>
      {React.cloneElement(this.props.children || <div />, { className: 'test' })}
  <Footer/>
</div>

但它不起作用。

我假设className继续使用Route组件而不是传递给Route组件的组件?

0 个答案:

没有答案