In create-react-app, adding Bootstrap 4?

后端 未结 5 1679
迷失自我
迷失自我 2021-02-07 08:01

Since create-react-app hides Webpack config without having to use eject, if I want to use something like reactstrap or react-bootstrap, should I eject or will I be

5条回答
  •  忘了有多久
    2021-02-07 08:52

    It's easier now with the latest version of bootstrap: https://getbootstrap.com/docs/4.1/getting-started/webpack/

    Install bootstrap and dependencies:

    npm install bootstrap jquery popper.js --save
    

    Then in your app entry point (index.js) import bootstrap and the css:

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

    Good to go!

    EDIT

    There's now a section in the create-react-app documentation: https://facebook.github.io/create-react-app/docs/adding-bootstrap#docsNav

    They mention react-bootstrap and reactstrap if you'd rather use that, and you will not need to eject.

提交回复
热议问题