1

Describe the bug In my React Typescript project, I am trying to use CSS modules. I created the project using create-react-app, added TypeScript later. Then I followed the instructions from the docs to setup CSS modules in the project

  1. Added the plugin with npm install -D typescript-plugin-css-modules
  2. Then updated tsconfig.json
{
  "compilerOptions": {
    "plugins": [{ "name": "typescript-plugin-css-modules" }]
  }
}
  1. I tried to run it but it didn't run. It complained about import statement here. Though the plugin docs say it shouldn't
  2. So I added global.d.ts, which resolved the error
  3. Now when I run it, the Home link on the header should be white. But I see the default color

To Reproduce

  1. Go to https://codesandbox.io/s/summer-haze-ztnf6?file=/src/index.tsx
  2. See the Link Home

Expected behavior Home link color should be white

2 Answers 2

1

Since you already solved the issue, please have a look for description: problem in accessing the scss variables in react components

in a similar way you can access classes from the module scss files.

Sign up to request clarification or add additional context in comments.

Comments

0

Never mind, changing the name of the scss file to header.module.scss fixed the issue.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.