2

How can I use reactstrap when CSS module is enable? it seem reactstrap is not working properly. I use to call css by className={classes.mycss} but then I follow instruction here https://reactstrap.github.io/ and still it didnt work. Also I imported the bootstrap css in my index.js. Any idea how to fix this?

index.js

import 'bootstrap/dist/css/bootstrap.css';

myComponent

import { Button } from 'reactstrap';

1 Answer 1

1

There are certain problems with this approach:

  1. CSS Modules localises the classnames to the module it is imported in, so if you import boostrap css, you will have to repeat that in every module.
  2. CSS Modules requires classnames that are in camel case, which the bootstrap version is not.
  3. Bootstrap styles are not written to be localised to a language. They are often meant to be shared.
  4. Even if we use packages like Bootstrap CSS Modules, Reactstrap depends on the global classnames and will not work.

The way to the solve this problem might be to add bootstrap as a global stylesheet file and use classNames instead of CSS Modules specific styleName. You can do this by:

  1. Adding a link tag to index.html file.

You can find the discussion here

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

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.