之前在 react-router v3.* 中,我通过 props 向子组件传递数据:
React.cloneElement(this.props.children, this.props)
在React-router v4中,如何使用新的<Match />
API进行操作?
到目前为止,我想到的解决方法是使用<Match />
API中的render
方法:
<Match pattern="/" render={() => <ChildComponent {...this.props} />} />
使用ES6展开语法将props传递给子组件。是否有更好的方法,可以同时将所有标准props(位置,模式,路径名,isExact)传递给子组件?