如果我每次连接时都通过所有状态,redux 和性能会受到影响吗?

redux and performance hit if I pass all of the state each time on connect?

我很好奇关于 Redux 和 React 是否有以下性能影响。

单页应用程序

  1. 我有数百个组件
    • 而不是明确说明我想要状态树的哪一部分。我将所有状态树交还给我连接的每个组件。

State Tree 包含许多具有数百个数据点和浅层深度数据结构的 reducer。

因此,例如。在我的 Shoe 组件中,带有状态的道具目前看起来像:

class Shoe extends Component{}
// result of connect and my full load of redux state
// this will all grow as the applications grow
this.props.state => {
   shoes: {},
   cost: {},
   customer: {},
   bikes: {},
   cars: {},
   colors: {}, 
   geo: {}
}

BUT, this particular component only needs shoes:
this.props.state => {
   shoes: {}
}

最初我认为,组件拥有一切是件好事,这样我就可以随意使用我 "could" 需要的一切。但是随着应用程序的不断发展壮大,我很好奇是否存在性能问题,可能导致数百个组件获得状态树的全部宽度,而不是选定的部分。当然,我减少了变异的可能性,但对这里的性能感到好奇。

我通过 Messenger 与 Dan 进行了非常简短的交谈,是的 - 性能受到了影响。

因此,我们希望将我们添加到道具上的状态限制为您只需要的状态。

因此,除非我听到任何不同的声音,否则我会认为这是正确的方法。