简体   繁体   English

undefined 不是一个函数(靠近'...icons.map...')React Native

[英]undefined is not a function (near '...icons.map...') React Native

I want to show my Bottom icons in the screen I have the array like this我想在屏幕上显示我的底部图标我有这样的数组

export const bottomTabIcons = [
{
    name: 'Home',
    active: 'https://img.icons8.com/fluency-systems-filled/48/ffffff/home.png',
    inactive: 'https://img.icons8.com/fluency-systems-regular/48/ffffff/home.png',
},
{
    name: 'Search',
    active: 'https://img.icons8.com/fluency-systems-filled/48/ffffff/search.png',
    inactive: 'https://img.icons8.com/fluency-systems-regular/48/ffffff/search.png',
},
{
    name: 'Reels',
    active: 'https://img.icons8.com/fluency-systems-filled/48/ffffff/video.png',
    inactive: 'https://img.icons8.com/fluency-systems-regular/48/ffffff/video.png',
},
{
    name: 'Shop',
    active: 'https://img.icons8.com/fluency-systems-filled/48/ffffff/shopping-bag-full.png',
    inactive: 'https://img.icons8.com/fluency-systems-regular/48/ffffff/shopping-bag-full.png',
},
{
    name: 'Profile',
    active: 'https://img.icons8.com/fluency-systems-filled/48/ffffff/user-male-circle.png',
    inactive: 'https://img.icons8.com/ios/48/ffffff/user-male-circle.png',
}

] ]

Bottom Tabs Component like this像这样的底部标签组件

const BottomTab = (icons) => {
const [activeTab, setActiveTab] = useState('HOME')

const Icon = ({icon}) => (
    <TouchableOpacity onPress={() => setActiveTab(icon.name)}>
        <Image source={{uri: icon.active}} style={styles.icon} />
    </TouchableOpacity>
)
return (
    <View>
        {icons.map((icon, index) => (
            <Icon key={index} icon={icon} />
        ))}
    </View>
)

} }

Because I am accessing it on home screen I do have access it like this,因为我是在主屏幕上访问它,所以我确实可以这样访问它,

<BottomTab icons={bottomTabIcons} />

It's erroring out for this这是错误的

{icons.map((icon, index) => (
            <Icon key={index} icon={icon} />
        ))}

How to solve that...怎么解决啊...

const BottomTab = ({icons}) => {}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Undefined 不是 function('...item.map...' 附近)-React Native 搜索栏 - Undefined is not a function (near '…item.map…')-React Native search bar React native Undefined 不是函数(&#39;...data.map...&#39; 附近) - React native Undefined is not a function (near '...data.map...') React Native TypeError undefined is not a function(靠近'...data.map...') - React Native TypeError undefined is not a function (near '…data.map…') undefined is not a function (near '...data.map...') |React native - undefined is not a function (near '…data.map…') |React native (React Native) passing props with Map function undefined is not a function (near '...resturants.map...') - (React Native) passing props with Map function undefined is not a function (near '...resturants.map...') React native: TypeError: undefined is not a function (near '...data.map...') 关于构建一个简单的应用程序 - React native: TypeError: undefined is not a function (near '...data.map...') on building a simple app Receiving TypeError: undefined is not a function (near&#39;...posts.map...&#39;) React-Native / Rails 6.0 API - Receiving TypeError: undefined is not a function (near'...posts.map...') React-Native / Rails 6.0 API 未定义不是 function(靠近'... map ...') - Undefined is not a function (near '… map …') React - “TypeError: undefined is not a function (near '...formFields.map...')” - React - “TypeError: undefined is not a function (near '…formFields.map…')” React Native AsyncStorage TypeError: undefined is not a function (near '...state.reduce...') - React Native AsyncStorage TypeError: undefined is not a function (near '...state.reduce...')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM