react-navigation / react-navigation/react-navigation

Screens not visible when using Material Top Tab Navigator inside of FlatList.

Open
#10,361 24 comments 16 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug library:react-native-pager-view package:material-top-tabs package:stack platform:ios repro provided
Dominant language
TypeScript
Stars
24.5k
Forks
5.1k
Avg merge
1d 5h
Merged PRs (30d)
18

Description

Current behavior

The tab screens are not visible - despite setting flex: 1.

Screen Shot 2022-02-17 at 12 18 22 AM
export default function TabsScreen() {
  return (
    <View style={{ flex: 1 }}>
      <Tab.Navigator>
        <Tab.Screen name="ScreenOne" component={ScreenOne} />
        <Tab.Screen name="ScreenTwo" component={ScreenTwo} />
      </Tab.Navigator>
    </View>
  );
}

It is not until I set a fixed height that the screen content appears:

Screen Shot 2022-02-17 at 12 20 10 AM
<View style={{ flex: 1, height: 100 }}>
Expected behavior

I expect the tab screens to be visible when using flex: 1. It is not acceptable to use a fixed height as I would like to include variable-height content in the tab screens - such as a FlatList. I also want to keep the parent-level FlatList - as I would like to utilize sticky headers. I've also tried using SectionList as the parent-level VirtualizedList, and I experience the same issue.

Here is the minimum structure:

|Stack Navigator
|- Screen
|-- FlatList
|--- item 1 - component
|--- item 2 - component
|---- Material Top Tab Navigator
|----- n-number of screens

Reproduction

https://snack.expo.dev/CCbZk7c0u

Platform
  • Android
  • iOS
  • Web
  • Windows
  • MacOS
Packages
  • @react-navigation/bottom-tabs
  • @react-navigation/drawer
  • @react-navigation/material-bottom-tabs
  • @react-navigation/material-top-tabs
  • @react-navigation/stack
  • @react-navigation/native-stack
Environment
  • [] I've removed the packages that I don't use
package version
@react-navigation/native 6.0.8
@react-navigation/material-top-tabs 6.1.1
@react-navigation/stack 6.1.1
react-native-safe-area-context 3.3.2
react-native-screens 3.8.0
react-native-gesture-handler 1.10.2
react-native-tab-view 3.0.0
react-native-pager-view 5.4.6
react-native 0.63.4
node 15.8.0
npm or yarn yarn

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Expo Snack reproduction and the parent FlatList/SectionList structure using Material Top Tab Navigator. Compare the listed package versions while investigating why flex: 1 does not show variable-height tab content. Done means the tab screens render inside the parent list without requiring a fixed height; no repository file or test is named.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.