react-native-collapsible-tab-view icon indicating copy to clipboard operation
react-native-collapsible-tab-view copied to clipboard

FlashList won't render properly in android.

Open isToThyMoon opened this issue 1 year ago • 5 comments

I wrote a demo based on the official example. The code is from '/example/src/FlashList.tsx'.

But when i opened it in android simualtor, i got a warning: ' FlashList's rendered size is not usable. Either the height or width is too small (<2px). Please make sure that the parent view of the list has a valid size. FlashList will match the size of the parent.'

And the content area was blank. FlashList was not rendered properly. But it works fine on IOS plantform. Screenshot_1716728777 I think it maybe the android 'flex:1' problem. So I go to the source code 'src/Container.tsx'.

            <AnimatedPagerView
              ref={containerRef}
              onPageScroll={pageScrollHandler}
              initialPage={index.value}
              {...pagerProps}
              style={[pagerProps?.style, StyleSheet.absoluteFill]}
            >
              {tabNamesArray.map((tabName, i) => {
                return (
                  <View key={i}>
                    <TabNameContext.Provider value={tabName}>
                      <Lazy
                        startMounted={lazy ? undefined : true}
                        cancelLazyFadeIn={!lazy ? true : !!cancelLazyFadeIn}
                        // ensure that we remount the tab if its name changes but the index doesn't
                        key={tabName}
                      >
                        {
                          React.Children.toArray(children)[
                            i
                          ] as React.ReactElement
                        }
                      </Lazy>
                    </TabNameContext.Provider>
                  </View>
                )
              })}
            </AnimatedPagerView>

And find the function tabNamesArray.map() returns the View Component, where the FlashList would be rendered. But only have key={i} in its props. If I add style={{ flex: 1}}, it will render FlashList properly.

 <View key={i} style={{ flex: 1}}>
    <TabNameContext.Provider value={tabName}>
      <Lazy
        startMounted={lazy ? undefined : true}
        cancelLazyFadeIn={!lazy ? true : !!cancelLazyFadeIn}
        // ensure that we remount the tab if its name changes but the index doesn't
        key={tabName}
      >
        {
          React.Children.toArray(children)[
            i
          ] as React.ReactElement
        }
      </Lazy>
    </TabNameContext.Provider>
  </View>

Is this a bug or I did not use the Tab.FlashList rightly? all my demo codes are from Example folder. But some days ago i did not face the problem.

Thanks.

isToThyMoon avatar May 26 '24 13:05 isToThyMoon

Adding { flex: 1} really did the trick, thanks.

virendrasingh-tech avatar Jul 10 '24 10:07 virendrasingh-tech

same question

chen8520 avatar Jul 25 '24 11:07 chen8520

Same issue with my also getting this error in android but working fine in ios, any idea please suggest.

ursnj avatar Aug 23 '24 10:08 ursnj

Same issue with my also getting this error in android but working fine in ios, any idea please suggest.

+1

pangxzi avatar Sep 29 '24 08:09 pangxzi

This patch should help react-native-collapsible-tab-view+8.0.0.patch

maherzaidoune avatar Oct 03 '24 19:10 maherzaidoune

Had the same issue right after we bumped react-native from 73 to 75 - patching the library with the fix from https://github.com/PedroBern/react-native-collapsible-tab-view/pull/448 worked for us thanks @maherzaidoune

gkartalis avatar Nov 07 '24 10:11 gkartalis

This patch should help react-native-collapsible-tab-view+8.0.0.patch

Some how this patch is not working with latest expo code.

ursnj avatar Feb 03 '25 06:02 ursnj