icons-pack / react-simple-icons

📦 This package provides the Simple Icons packaged as a set of React components.
MIT License
295 stars 18 forks source link

Typescript: Unable to add className prop #136

Closed justinwaite closed 2 years ago

justinwaite commented 2 years ago

Hello!

Since the upgrade to version 5, I am unable to specify a className prop on the icons. Although it still technically works, it does cause a typescript error.

Example:

import { Github } from "@icons-pack/react-simple-icons";

<Github className="mr-2 w-5 h-5" /> Sign in with Github

There are a few ways that this could be handled. Either you could extend the SVG props as defined by React, or create a shared interface that all of the icons extend (if you want more control over what props users should pass through).

I'm happy to assist in any way, just let me know what course of action you prefer to take.

justinwaite commented 2 years ago

I would recommend updating the component generator to do the following for props:

export type ${componentName}Props = React.ComponentPropsWithoutRef<'svg'> & {

or something similar

wootsbot commented 2 years ago

@justinwaite thank you very much for the contribution, merge your pull request