ReactJS: Why use this.props.children?

前端 未结 4 572
执笔经年
执笔经年 2021-01-01 16:11

I\'ve realised that none of the components I write use {this.props.children}.

I tend to compose my components the way the official docs state at the top

4条回答
  •  被撕碎了的回忆
    2021-01-01 16:53

    Some components don't know their children ahead of time. This is especially common for components like Sidebar or Dialog that represent generic "boxes".

    We recommend that such components use the special children prop to pass children elements directly into their output: Read More...

提交回复
热议问题