gajus / babel-plugin-react-css-modules

Transforms styleName to className using compile time CSS module resolution.
Other
2.05k stars 162 forks source link

With Typescript,How can I use props 'styleName' on tag <div> #269

Open lcnxx opened 4 years ago

gustavocd commented 4 years ago

Just add the types for react-css-modules:

npm install --save @types/react-css-modules

Check the package here

EmiyaYang commented 4 years ago

The react-css-modules is desperated now and it doesn't work for me.

EmiyaYang commented 4 years ago

This works for me.

// global.d.ts
import 'react';

declare module 'react' {
  interface Attributes {
    styleName?: string;
  }
}
max-mykhailenko commented 1 year ago

@EmiyaYang your solution doesn't work with typescript 4.3.5 and react 17.0.2 Got Property 'styleName' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'

Maybe you have some thoughts how to fix that