我正在做一個使用本機反應的專案。在那我遇到了以下錯誤
(注意:我正在使用 react-native 創建一個 android 應用程式,因為當我點擊搜索欄時,我遇到如下錯誤。請幫我清除錯誤)
Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of `SearchedProduct`.
in SearchedProduct (created by ProductContainer)
in RCTView (created by View)
in View
in Unknown
in Box
in Container
in ProductContainer (created by App)
in RCTView (created by View)
in View (created by App)
in $dac019021ac61f1f$export$9f8ac96af4b1b2ae (created by NativeBaseProvider)
in ToastProvider (created by NativeBaseProvider)
in PortalProvider (created by NativeBaseProvider)
in HybridProvider (created by NativeBaseProvider)
in ResponsiveQueryProvider (created by NativeBaseProvider)
in RNCSafeAreaProvider (created by SafeAreaProvider)
in SafeAreaProvider (created by NativeBaseProvider)
in NativeBaseConfigProviderProvider (created by NativeBaseProvider)
in NativeBaseProvider (created by App)
in App (created by ExpoRoot)
in ExpoRoot
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
我在這里附上我的代碼https://snack.expo.dev/@naheeda24/animal-feedmart。你能幫我解決這個錯誤嗎
提前致謝
uj5u.com熱心網友回復:
問題的根源在于CategoryFilter.js。在這個組件中,您使用的是ListItemfrom native-base。native-base該組件在版本中不存在3.3.7(我不知道它存在于哪個版本中)。
然而, aListItem實際上只是View帶有一些額外填充的 a。因此,您可以將其洗掉ListItem并替換為Viewfromreact-native并添加您想要的樣式。
這是更新的CategoryFilter.js.
import React from 'react';
import { StyleSheet, TouchableOpacity, ScrollView, View } from 'react-native';
import { Badge, Text} from 'native-base';
const CategoryFilter = (props) => {
return(
<ScrollView
bounces={true}
horizantal = {true}
style = {{ backgroundColor: "#f2f2f2" }}
>
<View style = {{ margin: 0, padding: 0, borderRadius: 0}}>
<TouchableOpacity
key={1}
// onPress{()}
>
<Badge
style={[styles.center, {margin: 5}]}
>
<Text style={{ color: 'white' }}>name</Text>
</Badge>
</TouchableOpacity>
</View>
</ScrollView>
)
}
const styles = StyleSheet.create({
center: {
justifyContent: 'center'
}
})
export default CategoryFilter;
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/457208.html
標籤:反应式
