反应本机意外令牌"{"。 导入调用只需要一个参数



大家好,我是React Native的新手,我正在YouTube上学习教程。在那里我导入了英雄图标,因为这是我需要做的。在我导入像这样的实际图标之前,一切都很好:

import { UserIcon, ChevronDownIcon, SearchIcon, AdjustmentsIcon, } from "react-native-heroicons/outline"

然后出现错误:Unexpected token '{'. import call expects exactly one argument. no stack。有没有人知道我该怎么解决这个问题,因为到目前为止我发现的一切都不起作用。

我的依赖项:

"dependencies": {
"@react-navigation/native": "^6.0.11",
"@react-navigation/native-stack": "^6.7.0",
"@react-navigation/stack": "^6.2.2",
"expo": "~46.0.6",
"expo-status-bar": "~1.4.0",
"react": "18.0.0",
"react-native": "0.69.4",
"react-native-heroicons": "^2.2.0",
"react-native-safe-area-context": "4.3.1",
"react-native-screens": "~3.15.0",
"react-native-svg": "12.3.0",
"react-navigation-stack": "^2.10.4",
"tailwindcss-react-native": "^1.7.10"
},

主页屏幕:

import { View, Text, SafeAreaView, StyleSheet, Platform, StatusBar, Image } from 'react-native';
import React, { useLayoutEffect } from 'react';
import { useNavigation } from '@react-navigation/native';
import { UserIcon, ChevronDownIcon, SearchIcon, AdjustmentsIcon, } from "react-native-heroicons/outline"
const HomeScreen = () => {
const navigation = useNavigation();
useLayoutEffect(() => {
navigation.setOptions({
headerShown: false,
});
}, [])
return (
<SafeAreaView style={styles.AndroidSafeArea}>
<Text className='text-red-500'>

{/* Header */}
<View className="flex-row pb-3 items-center mx-4 space-x-2">
<Image
source={{
uri: 'http://links.papareact.com/wru'
}}
className='h-7 w-7 bg-gray-300 p-4 rounded-full'
/>
<View>
<Text className="font-bold text-gray-400 text-xs">
Deliver Now!
</Text>
<Text className="font-bold  text-xl">
Current Location
<ChevronDownIcon size={20} color="#00CCBB"/>
</Text>
</View>
</View>
</Text>
</SafeAreaView>
)
}
const styles = StyleSheet.create({
AndroidSafeArea: {
flex: 1,
backgroundColor: "white",
paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0
}
})
export default HomeScreen

谢谢你的帮助:(

我遇到了同样的问题,如果您使用expo-start或npx-expo-start运行应用程序,您应该会看到它们在告诉您问题所在。我的问题是react原生svg版本被雇佣了,然后expo被期望我只运行expo doctor-修复依赖性,它应该修复安装了的react原生svg版本

最新更新