babel-plugin-react-css-modules icon indicating copy to clipboard operation
babel-plugin-react-css-modules copied to clipboard

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

Open lcningx opened this issue 6 years ago • 4 comments

lcningx avatar Aug 22 '19 07:08 lcningx

Just add the types for react-css-modules:

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

Check the package here

gustavocd avatar Aug 26 '19 16:08 gustavocd

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

EmiyaYang avatar May 09 '20 08:05 EmiyaYang

This works for me.

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

declare module 'react' {
  interface Attributes {
    styleName?: string;
  }
}

EmiyaYang avatar May 09 '20 09:05 EmiyaYang

@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

max-mykhailenko avatar Feb 21 '23 16:02 max-mykhailenko