react-navigation / react-navigation

Routing and navigation for your React Native apps
https://reactnavigation.org
23.61k stars 5.04k forks source link

DrawerContentScrollView don't show children #11671

Closed Yueyanc closed 11 months ago

Yueyanc commented 1 year ago

Current behavior

Child components of DrawerContentScrollView are not displayed

const DrawerContent: React.FC<Props> = props => {
  return (
    <SafeAreaView edges={['right', 'bottom', 'left']} style={{flex: 1}}>
        <DrawerContentScrollView
          {...props}
          contentContainerStyle={{flexGrow: 1, paddingTop: 0}}>
          {drawerItems.map((item, index) => {
            return (
              <DrawerItemRow
                {...props}
                key={index}
                icon={item.icon}
                label={item.label}
              />
            );
          })}
        </DrawerContentScrollView>
      </View>
    </SafeAreaView>
  );
};

DrawerContentScrollView source code

function DrawerContentScrollView(
  { contentContainerStyle, style, children, ...rest }: Props,
  ref?: React.Ref<ScrollView>
) {
  const drawerPosition = React.useContext(DrawerPositionContext);
  const insets = useSafeAreaInsets();

  const isRight = I18nManager.getConstants().isRTL
    ? drawerPosition === 'left'
    : drawerPosition === 'right';

  return (
    <ScrollView
      {...rest}
      ref={ref}
      contentContainerStyle={[
        {
          paddingTop: insets.top + 4,
          paddingStart: !isRight ? insets.left : 0,
          paddingEnd: isRight ? insets.right : 0,
        },
        contentContainerStyle,
      ]}
      style={[styles.container, style]}
    >
      {children}
    </ScrollView>
  );
}

export default React.forwardRef(DrawerContentScrollView);

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

When I comment out the "flex:1" in the source code, it appears normally

Expected behavior

show children components

Reproduction

https://github.com/react-navigation

Platform

Packages

Environment

github-actions[bot] commented 1 year ago

Hey @chenzhuo198! Thanks for opening the issue. It seems that the issue doesn't contain a link to a repro.

The best way to get attention to your issue is to provide an easy way for a developer to reproduce the issue.

You can provide a repro using any of the following:

github-actions[bot] commented 11 months ago

Hello 👋, this issue has been open for more than a month without a repro or any activity. If the issue is still present in the latest version, please provide a repro or leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution or workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix it.