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

How to use an Intrinsic attributes as types in TypeScript react-native

$
0
0

How do you make use of Intrinsic attributes as types in typeScript.

I have a simple tab navigation that looks like:

  const getOptions = (iconName: string) => ({    tabBarIcon: ({ color }: { color: string }) => (<MaterialIcons name={iconName} size={24} color={color} />    ),  });<Tab.Navigator><Tab.Screen        name="HomeScreen"        component={HomeScreen}        options={() => getOptions("home")}      /></Tab.Navigator>

MaterialIcons from @expo/vector-icons has a property name which is of type GLYPHS.

When I use iconName: string I get the following error:

The expected type comes from property 'name' which is declared here ontype 'IntrinsicAttributes & IntrinsicClassAttributes

What am I doing wrong?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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