Ilya Ivanov gave a talk on optimizing React Native rendering performance. He began by showing how performance degraded as the amount of data increased in an unoptimized app. He then demonstrated several techniques to avoid redundant renders, including shouldComponentUpdate, PureComponent, React.memo, and useCallback. Ivanov also discussed optimizing styles and handling props properly. His optimized app showed significant performance gains even with larger data sets. In summary, he emphasized measuring first, focusing on potentially unlimited content, and not sacrificing developer experience or functionality during optimization efforts.
13. Summary
• Performance is already slow for small sample 100 artists (500ms)
• Performance degrades with more data
• Slow responsiveness stack because of JS single threaded
14. Where to focus our effort
• 1 to * relationships in our hierarchy
• <FlatList or {items.map(item => …}
• No control over the number of items in our hierarchy
16. Update Complexity (big O for onPress)
• Current – O(n * m)
• n – number of artists
• m – number of boxes
• Goal – O(1)
Page
Artist 1
StatusBar
Box 1 Box 2... Box 8
Artist 2 …
StatusBar2
Artist N
StatusBarN
17. How to avoid redundant renders
• shouldComponentUpdate
• PureComponent
• React.memo
19. PureComponent
Used for classes. Shallow compare === for all properties of props, state
and context
React.memo
Used for function. Shallow compare === for all properties of props and
context
26. Fast refresh replaces hot refresh and live
reloading
onPress = (id) => {
// works fine since 0.61
}
renderArtist(artist) {
return (
<ArtistInfo
id={artist.id}
onPress={this.onPress}
/>
);
}
45. Summary
• React-Native doesn’t have to have performance problems
• Focus on measurement first, then optimize
• Prioritize potentially limitless content
• When optimizing don’t overlook developer experience and
functionality