mirror of
https://github.com/status-im/react-native.git
synced 2025-01-10 09:35:48 +00:00
1832d79bd1
Summary:**Motivation** Multiple instances of `Text` inside a `ListView` is a bad idea for the performance of the app. When you create 1000 elements and you scroll through the list it is really slow and laggy because the `NSTextStorage`, which is the backbone of the `RCTText` element, will set more than 1,000 times and also the method `setNeedsDisplay` is called multiple times. This will causes huge memory problems and the app crashes. With this commit I check in `RCTText` if the `NSTextStorage` differs from the old value. If yes then set it otherwise don't set the `NSTextStorage`. This will prevent to call `setNeedsDisplay` when not really needed. Gist with sample app to show behavior can be found here: https://gist.github.com/bpoetzschke/28a17969c6aa54219e18 Closes https://github.com/facebook/react-native/pull/6341 Differential Revision: D3035485 Pulled By: nicklockwood fb-gh-sync-id: 181f01b7f87f765dbb01a4ad3196fc40f9d50694 shipit-source-id: 181f01b7f87f765dbb01a4ad3196fc40f9d50694