diff --git a/contributingGuides/STYLE.md b/contributingGuides/STYLE.md index 6af3a82c2ff..30481133291 100644 --- a/contributingGuides/STYLE.md +++ b/contributingGuides/STYLE.md @@ -50,6 +50,9 @@ - [Stateless components vs Pure Components vs Class based components vs Render Props](#stateless-components-vs-pure-components-vs-class-based-components-vs-render-props---when-to-use-what) - [Use Refs Appropriately](#use-refs-appropriately) - [Are we allowed to use [insert brand new React feature]?](#are-we-allowed-to-use-insert-brand-new-react-feature-why-or-why-not) +- [Handling Scroll Issues with Nested Lists in React Native](#handling-scroll-issues-with-nested-lists-in-react-native) + - [Wrong Approach (Using SelectionList)](#wrong-approach-using-selectionlist) + - [Correct Approach (Using SelectionList)](#correct-approach-using-selectionlist) - [React Hooks: Frequently Asked Questions](#react-hooks-frequently-asked-questions) - [Onyx Best Practices](#onyx-best-practices) - [Collection Keys](#collection-keys) @@ -1105,6 +1108,48 @@ There are several ways to use and declare refs and we prefer the [callback metho We love React and learning about all the new features that are regularly being added to the API. However, we try to keep our organization's usage of React limited to the most stable set of features that React offers. We do this mainly for **consistency** and so our engineers don't have to spend extra time trying to figure out how everything is working. That said, if you aren't sure if we have adopted something, please ask us first. + +## Handling Scroll Issues with Nested Lists in React Native + +### Problem + +When using `SelectionList` alongside other components (e.g., `Text`, `Button`), wrapping them inside a `ScrollView` can lead to alignment and performance issues. Additionally, using `ScrollView` with nested `FlatList` or `SectionList` causes the error: + +> "VirtualizedLists should never be nested inside plain ScrollViews with the same orientation." + +### Solution + +The correct approach is avoid using `ScrollView`. You can add props like `listHeaderComponent` and `listFooterComponent` to add other components before or after the list while keeping the layout scrollable. + +### Wrong Approach (Using `SelectionList`) + +```jsx + + Header Content + +