javascript - 使用扩展运算符将所有道具传递给反应组件是否有性能成本
问题描述
目前我发现自己编写了很多组件,如下所示:
export default class MyComponent extends Component {
constructor(props) {
super(props)
this.state = {
someState1: 'something',
someState2: 'something',
someState3: 'something'
}
}
render() {
return (
<ComponentOne prop1={this.someState1} {...this.props}/>
<ComponentTwo prop2={this.someState2} {...this.props}/>
<ComponentThree prop3={this.someState3} {...this.props}/>
)
}
}
更高级别的状态像往常一样通过道具传递并传播到子组件中。
在某些情况下,我发现我将所有道具分散到每个子组件中,因为它比指定道具更快/更容易。
所以问题是:
- 将所有道具分散到每个组件中是否会产生性能成本,即使可能有 10 个子组件?
- 我应该更具体地说明传递给每个组件的道具吗?
- 对每个子组件执行此操作有什么缺点吗?
解决方案
推荐阅读
- python - 有没有办法在pygame中截取“截图”,然后将其保存为精灵以降低代码复杂度?
- python - 加快 statsmodels.nonparametric.kernel_regression.KernelReg 初始化的任何方式
- r - R:ggplot自定义变换轴标签以减少零
- java - JDBC BigDecimal - 精度问题
- .net-core - 在 Visual Studio 2019 中搜索拥有程序集的 NuGet 包
- rust - 返回 Box<[Box<[JsValue]>]> 不起作用,因为 IntoWasmAbi 未实现
- python - 将 .zip 存档中的大文件写入 Pandas 数据框
- hugo - Hugo 无法将 page.PagesGroup 类型转换为 Pages
- javascript - 使用 MongoDB 在 Express 中填充相关下拉框
- bit-manipulation - 是否有标准,如何以大端方式打包非字节对齐的位?