oblador / react-native-vector-icons

Customizable Icons for React Native with support for image source and full styling.
https://oblador.github.io/react-native-vector-icons/
MIT License
17.31k stars 2.12k forks source link

No TS autocomplete for Icon component prop (name prop) #1396

Open hadnet opened 2 years ago

hadnet commented 2 years ago

Using @expo version I got Icon name prop autocomplete, just implementing:

type IoniconsIconNames = keyof typeof Ionicons.glyphMap;

But I noticed that using this library I got no way of doing this because there is no glyphMap prop. So how do I get proper names autocomplete for Icon component using this library?

PS: I'm using this workaround below but I don't know if it is the right way to do this.

import Ionicons from 'react-native-vector-icons/dist/glyphmaps/Ionicons.json';

type IoniconsIconNames = keyof typeof Ionicons;
Kashifwahaj commented 2 years ago

Thanks It Really Helped.

usmansbk commented 1 year ago
import Icon from "@expo/vector-icons/MaterialCommunityIcons";
import { ComponentProps } from "react";

type Props = ComponentProps<typeof Icon>;
export type IconName = Props["name"];