-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
coming from here
Proposal
Split SelectionList into smaller, purpose-built list components
Strategy
Expensify’s blue ocean strategy depends on shipping features quickly without destabilising the app. Engineering velocity directly improves Free Cash Flow by reducing time spent on regressions and long PR cycles. Refactoring a critical UI primitive will shorten future feature lead-time and lower maintenance cost per customer seat.
Background
The highly adaptable SelectionList component is based on React Native’s SectionList, which demonstrates its flexibility for various purposes. It has become very complex, supporting over 90 properties and being used in 107 different components. This design was aimed at reducing repetition and covers many functionalities, making it a central component of many projects. On the other hand, developers often have to work with its many settings to make changes, which can easily cause regressions in some use cases. This complexity means there’s a lot for new developers to learn about how to use and integrate the component. A similar change was done recently where the refactoring of the SearchList sped up its rendering by 1.5 seconds (almost 40% improvement).
Problem
When a developer changes list behaviour in SelectionList, they modify a 90+ prop monolith referenced by 107 components, which frequently causes regressions and lengthens feature delivery time.
Solution
Break the current SelectionList down into several smaller, more focused components. Each component will be designed for a group of similar cases, making them simpler and more streamlined. This approach will reduce the complexity of each component, remove unnecessary props and simplify the operations inside. The plan for this refactoring involves the following steps:
- Audit usage across all 107 components to identify clusters of similar configurations and usage patterns.
- Define smaller components for each identified cluster, with logic and props needed only for the specific case.
- Gradual migration strategy - Introduce new components incrementally and replace existing SelectionList usages one by one to avoid large-scale disruption.
- Clean-up - Once all usages have been migrated, remove the original SelectionList.
- Define guidelines for contributor on how to decide when to create a new list and when it's still ok to update existing list knowing it will make it "heavier" and more compled
Advantages
This will result in:
- Improved performance: Fewer props and conditional branches will result in faster rendering and fewer re-renders.
- Better maintainability: Changes are isolated and the risk of regression is much smaller. Also testing will be faster as there would be less cases to check.
- Simpler debugging: Smaller, more specific components are easier and faster to understand and troubleshoot.
Issue Owner
Current Issue Owner: @JmillsExpensify
Metadata
Metadata
Assignees
Labels
Type
Projects
Status