Where to Import IconName interface from React Fontawesome with Typescript

Viewed 63

I'm trying to use FontAwesomeIcon dynamically but i'm having trouble in providing the icon name. This is my sample usage.

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

interface SampleProps {
  icon: string;
}

function SampleComponent(props: SampleProps) {
    return (
        <FontAwesomeIcon icon={['fas', props.icon ]} />
    )
}

It gives me this error

Type 'string' is not assignable to type 'IconName'.

Which can be solved if I declare my icon in my interface as IconName but I can't find it on the font-awesome library

0 Answers
Related