Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to use CSS modules in a React based WordPress plugin?

I have this line in one of my tsx file:

import styles from "../../styles/buyTicket.module.css";

got this error:

ERROR in /Applications/MAMP/htdocs/wp-content/plugins/tikex/tikexModule/components/BuyTicket/PricingOptionInvoiceItemsFormFieldsCheckboxes.tsx
./tikexModule/components/BuyTicket/PricingOptionInvoiceItemsFormFieldsCheckboxes.tsx 7:19-54
[tsl] ERROR in /Applications/MAMP/htdocs/wp-content/plugins/tikex/tikexModule/components/BuyTicket/PricingOptionInvoiceItemsFormFieldsCheckboxes.tsx(7,20)
      TS2307: Cannot find module '../../styles/buyTicket.module.css' or its corresponding type declarations.

If I remove styles then I got this error no more, but then it will work not as a CSS module, and naming collosion will happen. What would you suggest?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

As far as i can understand, you may have a look here:
Can't import CSS/SCSS modules. TypeScript says "Cannot Find Module"

and here:
React, Typescript – Cannot find module … or its corresponding type declarations

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading