Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

undefined is not an object ( evaluating Images.homeIcon.uri) only on emulator?

$
0
0

Hello guys im runnning into this error which I only get when I try to run the app on emulator. It works perfect on my physical device when I run it. The emulator device is a android 10 (google pixel 4a) , so I dont think if its the android version (my own device android version that I run the app on is 12). In the console it says its a 'type Error' undefined is not an object. the Code that causes is error is a image import here is the code

 homeIcon: {  uri: require('@/Assets/Svgs/homeIcon.png'),},

as said it works fine on physical device, and even with commenting out that line which is causing the issue , the app runs , but its all messed up, the themes none of them are working. here are more relevant codes :

    const Tab = createBottomTabNavigator()const getTabbarIcon = (icon: ImageSourcePropType) => {  return ({ color }: any) => (<Image style={{ tintColor: color, height: 30, width: 30 }} source={icon} />  )}// @refresh resetconst MainNavigator = () => {  const { NavigationTheme, NavigationColors, Images } = useTheme()  return (<Tab.Navigator      screenOptions={{        tabBarActiveTintColor: NavigationColors.activeTab,        tabBarItemStyle: {          padding: 10,        },        tabBarStyle: {          height: 70,          backgroundColor: NavigationColors.secondary,          marginHorizontal: 20,          marginBottom: 20,          borderRadius: 12,        },        tabBarShowLabel: false,      }}><Tab.Screen        name="Home"        component={Home}        options={{          header: () => (<View style={[tw`flex flex-row justify-between m-3`]}><Text style={tw`text-white text-2xl`}>Header</Text><Text style={tw`text-white`}>view all</Text></View>          ),          tabBarIcon: getTabbarIcon(Images.homeIcon.uri),        }}      /><Tab.Screen        name="Trading"        component={Trading}        options={{          headerShown: false,          tabBarIcon: getTabbarIcon(Images.chartIcon.uri),        }}      />

Im using boilerplate from this repository

my react native version is 0.66.4 .As said its not only about the images, everything about the theme just gets messed up when running on emulator. So if there is something ive missed except for the instructions from the docs, will appreciate a helping hand.ps I dont have any experience with RN, but have worked with React.Thanks.enter image description here


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>