If the component hierarchy is too deep, will it affect App performance? , if yes, how many levels will generally be set
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?
大家讲道理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.