我有一个ReactComponentParent,可以接收15个不同的道具(对象,数字,布尔值,数组等)
在ReactComponentParent内部,我有一个需要6个道具的ReactComponentChild,但我使用的是{... props}
<ReactComponentChild {...props} />
使用{... props}代替所需的道具有副作用吗? 是否以某种方式做出反应(例如通过propsTypes)来处理此行为? 我应该只发送组件需要的东西吗?
答案 0 :(得分:0)
这样,您会将所有来自父项的道具发送给子组件,例如
<ReactComponentChild {...props} />
一种好的方法是只将所需的道具发送给孩子