Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Advantages of using react-bootstrap over bootstrap

What's the point in using react-bootstrap over plain old Bootstrap?

I was going through https://react-bootstrap.github.io/components.html and I don't see any advantage. I can only see that it can bring unnecessary dependency to the project.

Is there any difficulty in using plain Bootstrap in React/Redux projects?

**EDIT **

Deducing from reading https://react-bootstrap.github.io/introduction.html is the only thing that react-bootstrap gives me the shorthand for class names? Below are the examples of the same page.

In plain boostrap I'd do:

var button = React.DOM.button({   className: "btn btn-lg btn-success",   children: "Register" });  React.render(button, mountNode); 

And in react-boostrap:

var button = ReactBootstrap.Button({   bsStyle: "success",   bsSize: "large",   children: "Register" });  React.render(button, mountNode); 

All these bsStyle, bsSize, ... from react-boostrap are the things people didn't like on Angular that have remember all those ng-* tags... I personally don't mind it but if it's the only thing that react-bootstrap gives me I will use twitter-bootstrap. Or did I miss something?

like image 868
Amio.io Avatar asked Jun 30 '16 12:06

Amio.io


People also ask

Is it better to use React-Bootstrap or Bootstrap?

You should use React-Bootstrap if: -You care about a clean and readable syntax of your components. -You want to use the 4th version of Bootstrap with all its JavaScript features. -You are new to the web development world and don't care about learning a new API.

Whats the difference between Bootstrap and React?

While Bootstrap is a template-based front-end framework, React is a component-based framework. The easiest way to choose between these two frameworks is based on their commercial possibilities and capacity to provide the most satisfactory project result.

What are the advantages of React over other frameworks?

Flexibility. Compared to other frontend frameworks, the React code is easier to maintain and is flexible due to its modular structure. This flexibility, in turn, saves huge amount of time and cost to businesses.

Do you need Bootstrap for React-Bootstrap?

Because React-Bootstrap doesn't depend on a very precise version of Bootstrap, we don't ship with any included CSS. However, some stylesheet is required to use these components.


2 Answers

React-bootstrap creates React components for you.

The advantage will be obvious if you consider how to do animations with the help of bootstrap in your React project.

Without react-bootstrap, you need something like CSSTransitionGroup. You cannot take advantage of bootstrap's API because it will manipulate the DOM, which makes the React behavior unpredictable. Also, bootstrap will hide details of their animation API; that is to say,you cannot use it at all.

With bootstrap components, however, you do not need to worry about how the animation is implemented by bootstrap, you just need to specify properties and hooks in a component and the library will do the trick. More specifically, it can add some wrappers which are not visible to the client.

enter image description here

As you can see above, <Fade> and <Transition> component is added by bootstrap.

In addition, the syntax of virtual DOM may not be compatible with DOM:

enter image description here

As shown above, putting <input> inside a <select> is a way of semantic UI, but React will complain. I expect the bootstrap may experience similar issues without a customized library.

like image 74
Guichi Avatar answered Sep 17 '22 11:09

Guichi


It's really a matter of what front-end framework you plan to use. If you are going to use Angular, Ember, Knockout, or plain old jQuery then traditional Bootstrap may be sufficient for you. With React though there is a fundamental difference in how the JavaScript application code interacts with the DOM that makes the jQuery approach from Bootstrap very difficult to work with since React primarily works with a Virtual DOM. It iss true that using React-Bootstrap will reduce the amount of boilerplate code that you would need to do simple tasks like Buttons or Form elements, though that's not the primary gain.

like image 35
Matt Smith Avatar answered Sep 17 '22 11:09

Matt Smith