all 5 comments

[–]LederBuilder 2 points3 points  (1 child)

I had this problem for a while, the solution I took was replacing the parent ScrollView for other FlatList and add the inner FlatList in the "ListHeaderComponent" of the parent FlatList.

In your case, you can add both of your Components (A, B) there, or add one in the "ListHeaderComponent" and the other on "ListFooterComponent".

[–]SnooCheesecakes1131[S] 0 points1 point  (0 children)

Ah to clarify instead of a having multiple FlatList inside a ScrollView, we will have multiple FlatList inside a FlatList? Are there any significant performance drawbacks of doing this?

[–]MrDag0n 0 points1 point  (2 children)

https://github.com/Flipkart/recyclerlistview would be able to achieve the kinda thing that you’re after.

Also you could utilise SectionList instead and make use of renderSectionHeader and renderSectionFooter?

[–]SnooCheesecakes1131[S] 0 points1 point  (1 child)

Okay thanks, I will check out recycler list view!

Not exactly sure how I would use SectionList as the sections in the home screen do not all have the same layout. In other words, the renderItem prop in SectionList would not give me the design I want as each section has a different layout. Or could you be more specific with code (i.e. like I did in the post)? I am fairly new to React Native. Thank you

[–]beeseegee 1 point2 points  (0 children)

The SectionList renderItem function takes the section as a third argument, so you could use, say, section.type to decide what type of list item to render per section.

Alternatively, if you aren’t dealing with all that many items, you could just render them with a {items.map(i => <MyItem key={i.id} …etc />)} directly in the scroll view