React系列之父组件如何传递Props给this.props.children

56 阅读1分钟
原文链接: alili.tech

问题

React使用router之后,以下形式会经常出现.

this.props.children

可是这样渲染出来的组件,父组件如何传递props给它呢?

解决

我们可以这样传递porps给子组件:

{ 
React.cloneElement(this.props.children,{A:xxx,B:xxx2,C:xxx3})

}