I'm trying to find out the type definitions for the icon name of MaterialCommunityIcons, since i am intending to use it for props.
Asked
Active
Viewed 2,682 times
2 Answers
24
React.ComponentProps<typeof MaterialCommunityIcons>['name']

double-beep
- 5,031
- 17
- 33
- 41

Paolo Vincent
- 377
- 3
- 9
-
3Another solution is: `let iconName: keyof typeof MaterialCommunityIcons.glyphMap;` – Ying Aug 14 '22 at 05:21
-
The accepted answer doesn't work for me. When I try to use a prop with that type as the `name` prop for a `MaterialCommunityIcons` element it gives a typescript error. Using the suggestion from @Ying works perfectly. I'll suggest an edit with that change. – stuckj Mar 27 '23 at 21:24
-2
Check out this site. provides icon name and preview.

Sense Kim
- 14
- 1
-
-
@SenseKim I am trying to find the Type definition, not the actual icon names, because I am using `icon name` as props – Paolo Vincent Mar 25 '21 at 14:58
-
@PaoloVincent What is the type you are talking about, for example? like 'Ionicons', 'MaterialCommunityIcons'? You can check and use it on that site. Another way is to find out what kind of icon is provided when [link](https://icons.expo.fyi/) clicks 'Filters' here. – Sense Kim Mar 26 '21 at 02:09
-
@SenseKim, Typescript. i want to get the type of the name prop of MaterialCommunityIcon, I want to specify the type instead of just 'string' – Paolo Vincent Mar 28 '21 at 12:37
-
@SenseKim, ```React.ComponentProps
['name']``` this is what i was looking for – Paolo Vincent Apr 12 '21 at 02:14