react-native-vector-icons icon indicating copy to clipboard operation
react-native-vector-icons copied to clipboard

No TS autocomplete for Icon component prop (name prop)

Open hadnet opened this issue 4 years ago • 2 comments

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;

hadnet avatar Nov 07 '21 19:11 hadnet

Thanks It Really Helped.

Kashifwahaj avatar Nov 17 '21 13:11 Kashifwahaj

import Icon from "@expo/vector-icons/MaterialCommunityIcons";
import { ComponentProps } from "react";

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

usmansbk avatar Mar 28 '23 03:03 usmansbk