PedroBern / react-native-collapsible-tab-view

A cross-platform Collapsible Tab View component for React Native
MIT License
836 stars 162 forks source link

If you don't pass a value to `renderHeader`, the tabs don't show up #39

Closed alexpchin closed 3 years ago

alexpchin commented 3 years ago

I have a couple of pages that require tabs that do not require a header. I thought that the default of renderHeader was () => null so passing no header would still display the tabs as if we were using react-native-tab-view.

<CollapsibleTabView<Route>
      navigationState={{ index, routes }}
      renderScene={renderScene}
      onIndexChange={handleIndexChange}
      // renderHeader={renderHeader}
      headerHeight={HEADER_HEIGHT}
      {...props}
    />

However, if you omit renderHeader, the tabs do not show.

Screenshot 2021-01-13 at 16 13 19

PedroBern commented 3 years ago

This bug was probably introduced at some point. This didn't use to happen. But I think there is no point in using it without the renderHeader, a better option is to use the regular tab view.

PedroBern commented 3 years ago

It is probably easy to fix, I will try to see it later. Or you can open a PR :)

alexpchin commented 3 years ago

It's useful to have if you want to conditionally render a header. I think it has something to do with this PR?

https://github.com/PedroBern/react-native-collapsible-tab-view/pull/18/files

PedroBern commented 3 years ago

yes you are right, probably here.

Not sure, but maybe this will fix:

--- {renderHeader()}
+++ {renderHeader && renderHeader()}
alexpchin commented 3 years ago

Hmmm... I don't think so... as renderHeader is defined by default? I think it's something to do with the value of translateY on the Animated.View

alexpchin commented 3 years ago

https://github.com/PedroBern/react-native-collapsible-tab-view/pull/40

PedroBern commented 3 years ago

@alexpchin released in v2.0.1 👍 thanks