为什么 children 不应该作为道具传递?

Why shouldn't children be passed as a prop?

根据ESLINT规则no-children-prop

When using JSX, the children should be nested between the opening and closing tags. When not using JSX, the children should be passed as additional arguments to React.createElement

这只是一个风格建议,还是会造成真正的损害?

这似乎更像是一种文体建议,也可以防止您搬起石头砸自己的脚。

如果你有一个组件:

<Component children="foo">bar</Component>

并在组件中执行

return (
  <div>
    {this.props.children}
  </div>
)

你最终会得到 bar 作为 this.props.children 而不是 foo 但就此破坏任何反应或导致 "damage" 我没有找到这样的证据,这里有一个冗长的讨论 https://github.com/airbnb/javascript/issues/1089#issuecomment-250640742 陈述相同。