Solution

To check whether bootstrap is the version in react js, we have to check how many ways have to install bootstrap in react.

we are going to check all the below ways of installation and check their versions.

  1. Using NPM or yarn
  2. Using CDN Link

So one by one, we will go will the following ways and check their installation steps after how to identify the version.

Using NPM or yarn

Most of the time, developers use NPM to install bootstrap in their projects and it is the best way to install and uninstall bootstrap.

Let’s see how we can check if bootstrap is installed with npm or yarn.

Identification

To identify the bootstrap version, Go TO the package.json file and search bootstrap if you get anywhere in your package dependencies their also mention the package version also.

package.json

{
  "name": "code-sandbox-examples",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "bootstrap": "^4.6.0",  // bootstrap installed
    "react": "^17.0.2",
    "react-bootstrap": "^1.5.2", // bootstrap installed
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Sometimes developers use the CDN link in react HTML file to install it, but I will not recommend this way.

Identification

To identify the bootstrap version if installed by CDN, go to your public/index.html file and search for bootstrap, and if you get any link tag with bootstrap their also mention their version like the below example.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />

    <!-- Including the bootstrap css via CDN -->
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
      integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
      crossorigin="anonymous"
    />

    <title>React-Bootstrap CodeSandbox Starter</title>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
  </body>
</html>