Reputation: 2968
I completed my application in react native
but after building its slow. Then I started to research to improve the performance of the application. I found this documentation on the official website of the react native
and I am sure this will help me but I am unable to get it into my head. Please can anyone tell in easy words what the following documentation is saying:
If you are using immutable data structures, this would be as simple as a reference equality check.
Similarly, you can implement shouldComponentUpdate and indicate the exact conditions under which you would like the component to re-render. If you write pure components (where the return value of the render function is entirely dependent on props and state), you can leverage PureComponent to do this for you. Once again, immutable data structures are useful to keep this fast -- if you have to do a deep comparison of a large list of objects, it may be that re-rendering your entire component would be quicker, and it would certainly require less code.
I will be glade. Thanks !!!
Upvotes: 0
Views: 60
Reputation: 295
If you're using a static object, you can render your component as a PureComponent like it says above. Then, you can pass it props or set the state with the words you want displayed.
When you do that, the FlatList will re-render only the portions of the data that it needs to, depending on what changed. What the last part of it is saying is that a PureComponent does shallow comparisons - if something in an array changes, but the array itself doesn't change, then your FlatList won't update. However, with an immutable object, you can always declare it as a PureComponent and it should be faster.
Upvotes: 1