How to include bootstrap css and js in reactjs app?

后端 未结 19 1142
既然无缘
既然无缘 2020-12-04 05:07

I am newb to reactjs, I want to include bootstrap in my react app

I have installed bootstrap by npm install bootstrap --save

Now, want to load b

19条回答
  •  既然无缘
    2020-12-04 05:47

    Just in case if you can use yarn which is recommended for React apps,

    you can do,

    yarn add bootstrap@4.1.1 // this is to add bootstrap with a specific  version
    

    This will add the bootstrap as a dependency to your package.json as well.

    {
      "name": "my-app",
      "version": "0.1.0",
      "private": true,
      "dependencies": {
        "bootstrap": "4.1.1", // it will add an entry here
        "react": "^16.5.2",
        "react-dom": "^16.5.2",
        "react-scripts": "1.1.5"
      },
      "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test --env=jsdom",
        "eject": "react-scripts eject"
      }
    }
    

    After that just import bootstrap in your index.js file.

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

提交回复
热议问题