我的一个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组件的组件?