Giter Site home page Giter Site logo

Comments (5)

PedroBern avatar PedroBern commented on May 2, 2024

The tabs follow the refMap object keys order, and your screen components also should match this order. How are your refMap and screens arranged?

from react-native-collapsible-tab-view.

alexpchin avatar alexpchin commented on May 2, 2024

Hi @PedroBern

My refMap is:

/**
 * This sets the names of the tabs
 */
const [refMap] = useState({
  [t('screens.Search.tabs.tattoos')]: tattoosRef,
  [t('screens.Search.tabs.artists')]: artistsRef,
  [t('screens.Search.tabs.studios')]: studiosRef,
  [t('screens.Search.tabs.collectors')]: collectorsRef,
});

With my Tab.Container code looking like:

<Tabs.Container
  containerRef={containerRef}
  HeaderComponent={_renderHeader}
  headerContainerStyle={TabBarStyle.headerContainerStyle}
  lazy
  onIndexChange={onIndexChange}
  refMap={refMap}
  snapEnabled
  TabBarComponent={_renderTabBar}
>
  <SearchTattoos name={t('screens.Search.tabs.tattoos')} />
  <SearchArtists name={t('screens.Search.tabs.artists')} />
  <SearchStudios name={t('screens.Search.tabs.studios')} />
  <SearchCollectors name={t('screens.Search.tabs.collectors')} />
</Tabs.Container>

This issue also appears in the example, displayed here: #79

from react-native-collapsible-tab-view.

alexpchin avatar alexpchin commented on May 2, 2024

Actually, I've just checked the current example for scrollable tabs, actually, the issue is also present there without any changes.

from react-native-collapsible-tab-view.

alexpchin avatar alexpchin commented on May 2, 2024

@PedroBern I've pushed what I think is a fix. I believe that we have to sort by onTabItemLayout by the x value as the order will be defined by the order that they are put on the screen, not their x position. After sorting I believe this is now working.

from react-native-collapsible-tab-view.

PedroBern avatar PedroBern commented on May 2, 2024

Hey alex I would recommend getting the tab names like this:

const [refMap] = useState({
  [screens.Search.tabs.tattoos]: tattoosRef,
  [screens.Search.tabs.artists]: artistsRef,
  [screens.Search.tabs.studios]: studiosRef,
  [screens.Search.tabs.collectors]: collectorsRef,
});

// on tabBar
getLabelText={(name) => t(name)}

Translating on the tab bar will prevent the whole thing to rerender if the user changes the idiom of the app.

from react-native-collapsible-tab-view.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.