WishList is a list component for React Native that aims to magically solve all of the performance problems of lists in React Native. 🪄🎩
In this document, I (Marc) am going to explain what WishList is, what problem it is solving, the full journey (1+ years!) of the development of the project, all the technical challenges we faced, and why we ultimately cannot release WishList as a production-ready library. (~25 minutes read)
First, some basic definitions:
Virtualization is when you are rendering a list of say 1000 items, but you only effectively mount/render a small batch of those (say 10) since the other 990 are outside of the viewport anyways. While scrolling, you continue to mount other items and could unmount the ones that become invisible. To the user, this looks like all 1000 items are available.
Recycling is similar to virtualization, except that you don’t mount/unmount cells when they become visible/invisible, but instead have a fixed pool of rendered items already on the screen (outside the viewport so the user doesn’t see them), and you just update their contents (e.g. a Text’s text
property) while scrolling.
This is even faster than normal virtualization since you don’t have to mount/unmount cells, but only update their contents (”rehydration”).
Cool, let’s go:
To understand what the performance problems of lists in React Native are, we need to understand what’s the de-facto standard for lists in React Native:
RCTScrollView
component under the hood, then virtualizes entirely on the JavaScript/React side.
As you can see, it is all based on one single native component: RCTScrollView.
At Margelo, we decided that we want to take a fundamentally different approach; we wanted to do the virtualization/recycling completely on the native side. It was good timing, Fabric was becoming more and more stable, it was possible to deal with C++ ShadowNodes yourself, and we had the perfect team to do it: