showing results for - "react native pure component vs component"
Lisa
28 Nov 2018
1The major difference between React.PureComponent and React.Component is PureComponent does a shallow comparison on state change. It means that when comparing scalar values it compares their values, but when comparing objects it compares only references. It helps to improve the performance of the app.
2
3You should go for React.PureComponent when you can satisfy any of the below conditions.
4
5    State/Props should be an immutable object
6    State/Props should not have a hierarchy
7    You should call forceUpdate when data changes
8
9If you are using React.PureComponent you should make sure all child components are also pure.
10
11    is there any performance impact in using React.component that we may consider going for React.PureComponent?
12
13Yes, it will increase your app performance (because of shallow comparison)
14
15    I am guessing shouldComponentUpdate() of Purecomponent performs only shallow comparisons . If this is the case can' t the said method used for deeper comparisons?
16
17You guessed it correctly. You could use it if you satisfy any of the conditions I mentioned above.
18
19    "Furthermore, React.PureComponent's shouldComponentUpdate() skips prop updates for the whole component subtree" - Does this mean that prop changes are ignored?
20
21Yes, prop changes will be ignored If it couldn't find difference in shallow comparison.
queries leading to this page
pure component vs componentspurecomponent vs component rerenderpure component reactdifference between purecomponent and componentpure components vs components reactdeclare pure componentreact native component vs purecomponentreact purecomponent vs componentdifference between pure component and componentreact pure componentpure react componentpure component vs component reactreact pure components vs reactreact purecomponent vs react componentdifference between a component and a pure componentpure componentsdifference between pure component and component react nativepure component react examplepure component vs react componentdifference between pure component and component in reactpure components vsreact purecomponent and statecomponent vs pure componentsreact purecomponent state react component and purecomponentreact native pure componentpure component vs component reactjspure and impure component react native site 3astackoverflow compure component vs component in reactdifference react pure component vs componentpure components vs componentswhat is the difference between a pure component and a regular component 3fcomponent vs purecomponent reactdifference between component and purecomponentpurecomponent vs component reactreact pure component vs componentwhat is the difference between purecomponent and component 3fpure component in reactreactjs pure component vs componentreact component vs purecomponentreact native pure component vs componentreact native pure component vs component