akveo / react-native-ui-kitten

:boom: React Native UI Library based on Eva Design System :new_moon_with_face::sparkles:Dark Mode
https://akveo.github.io/react-native-ui-kitten/
MIT License
10.19k stars 952 forks source link

hi, how to generate multiple tab in tabview #1812

Closed qzw881130 closed 2 weeks ago

qzw881130 commented 2 months ago

💬 hi, how to generate multiple tab in tabview

UI Kitten and Eva version

"@ui-kitten/components": "5.3.1",
"@ui-kitten/eva-icons": "5.3.1",
"@ui-kitten/metro-config": "5.3.1",
const Tabs = () => {
  return (
    <React.Fragment>
    {EshopsData.map((_, idx) =>(
        <Tab title={'aaa-'+idx}>
          <Layout style={styles.tabContainer}>
            <Text category='h5'>aaaa</Text>
          </Layout>
        </Tab>))}
    </React.Fragment>
  );
}

          <TabView
          selectedIndex={selectedIndex}
          shouldLoadComponent={shouldLoadComponent}
          onSelect={index => setSelectedIndex(index)}
          children={<Tabs />}
        >

        </TabView>

pls help me, tell me how to fix it?

qzw881130 commented 2 months ago

okay. i solved it. like this:

          <TabView
          selectedIndex={selectedIndex}
          shouldLoadComponent={shouldLoadComponent}
          onSelect={index => setSelectedIndex(index)}
          children={EshopsData.map(({category}, idx) =>(
            <Tab title={category} key={idx}>
              <Layout style={styles.tabContainer}>
                <Text category='h5'>aaaa</Text>
              </Layout>
            </Tab>))}
        >
        </TabView>