search

Home  >  Q&A  >  body text

React performance issues?

  1. If the component hierarchy is too deep, will it affect App performance? , if yes, how many levels will generally be set

  2. Redux generates a new state through the reducer every time it takes an action. If there are more actions, there will be more state objects. Will this not affect performance? How is redux circumvented?

伊谢尔伦伊谢尔伦2732 days ago932

reply all(3)I'll reply

  • 大家讲道理

    大家讲道理2017-07-05 11:04:11

    The problem of component nesting is unavoidable. In order to reuse code, it must be nested, otherwise the amount of code will be huge. This is also one of the disadvantages of react. Generally speaking, 3-5 levels of nesting can basically solve the problem, and it is estimated that it will be no problem if it is deeper. If it is too deep, the first problem you have to face is definitely not performance, but development. You may not remember where the parameters are passed from to where. You can add more code to reduce the reuse rate, but it is much easier to maintain and the performance is OK. As for the state issue, redux maintains a huge state. The entire project is a state, and small states are divided into individual components. Without a deep understanding of how the specific state operates, it seems that after a new state is generated, the original state becomes something like an object without references and will be released by the system.

    reply
    0
  • 扔个三星炸死你

    扔个三星炸死你2017-07-05 11:04:11

    Try immutable

    reply
    0
  • 滿天的星座

    滿天的星座2017-07-05 11:04:11

    virtual dom

    reply
    0
  • Cancelreply