[英]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.