React Bootstrap | What is React Bootstrap
React Bootstrap
Bootstrap 4 is the most popular CSS system for building responsive designs with numerous new highlights, for example, the help for Flexbox and another Card segment. Bootstrap 4 relies upon both jQuery and Popper.js yet utilizing jQuery with React isn't suggested since jQuery utilizes direct DOM control. React has the most utilized JavaScript system for building web applications, and Bootstrap become the most well known CSS structure.
With the assistance of Bootstrap, React bootstrap does something amazing with the entirety of the bootstrap themes which you like to utilize. The structure and the capacity of each component are constrained by the React part.
Adding Bootstrap to React
There are three common ways to add Bootstrap to the React App:-
- Using the Bootstrap CDN
- Bootstrap as Dependency
- React Bootstrap Package
Using the Bootstrap CDN
It is the easiest method of adding Bootstrap to the React application. There is no compelling reason to introduce or download Bootstrap. We can just put an <link> into the <head> area of the index.html document of the React application as appeared in the accompanying bit.
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
On the off chance that there is a need to utilize Bootstrap parts that rely upon JavaScript/jQuery in the React application, we have to incorporate jQuery, Popper.js, and Bootstrap.js in the record. Include the accompanying imports in the <script> labels close to the furthest limit of the end </body> tag of the index.html record.
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
In the above, we have utilized jQuery's slim form, although we can utilize the full form also. Presently, Bootstrap is effectively included in the React application, and we can utilize all the CSS utilities and UI segments accessible from Bootstrap in the React application.
Bootstrap as Dependency
On the off chance that we are utilizing a forming device or a module bundler, for example, Webpack, at that point, bringing in Bootstrap as dependency is the favored alternative for adding Bootstrap to the React application. We can introduce Bootstrap as a dependency for the React application. To introduce the Bootstrap, run the accompanying orders in the terminal window.
$ npm install bootstrap --save
When Bootstrap is introduced, we can import it in the React application passage document. If the React project made utilizing the make respond application apparatus, open the src/index.js document, and include the accompanying code:
import 'bootstrap/dist/css/bootstrap.min.css';
we can utilize the CSS classes and use them in the React application. Additionally, on the off chance that we need to utilize the JavaScript parts, we have to introduce the jquery and popper.js bundles from npm. To introduce the accompanying bundles, run the accompanying order in the terminal window.
$ npm install jquery popper.js
Next, go to the src/index.js document and include the accompanying imports. we can utilize Bootstrap JavaScript Components in the React application.
import $ from 'jquery';
import Popper from 'popper.js';
import 'bootstrap/dist/js/bootstrap.bundle.min';
React Bootstrap Package
The React Bootstrap bundle is the most well-known approach to include bootstrap in the React application. There are many Bootstrap bundles worked by the network, which intend to remake Bootstrap parts as React components. The two most well-known Bootstrap bundles are:
- Respond bootstrap: It is a finished re-usage of the Bootstrap segments as React segments. It needn't bother with any conditions like bootstrap.js or jQuery. On the off chance that the React arrangement and React-Bootstrap introduced, we have everything which we need.
- Reactstrap: It is a library that contains React Bootstrap 4 segments that favor piece and control. It doesn't rely upon jQuery or Bootstrap JavaScript. Be that as it may, respond popper is required for cutting edge situating of substance.
Let us make another React application utilizing the make respond application order as follows.
$ npm create-react-app reactstrap-app
Next, introduce the package using the pm.
$ npm install react-bootstrap bootstrap --save for react-bootstrap
$ npm install bootstrap reactstrap --save for reactstrap
Presently, open the src/index.js record and add the accompanying code to import the Bootstrap document.
import 'bootstrap/dist/css/bootstrap.min.css';
For react-Bootstrap, We can likewise import singular segments like import { SplitButton, Dropdown } from 'respond bootstrap'; rather than the whole library. It gives the particular segments which we have to utilize, and can essentially lessen the measure of code.
For Reactstrap, we can likewise import singular segments like import { Button, Dropdown } from ‘reactstrap'; rather than the whole library. It gives the particular component which we have to utilize, and can altogether decrease the measure of code.


