I found two different bootstraps for reactjs
What is the basic and main difference between both?
Unlike using Bootstrap in HTML, Reactstrap exports all the correct Bootstrap classes automatically, and don't need to use or include Bootstrap's JavaScript files or add data attributes to trigger functionality. Instead, components are defined in React-friendly components with appropriate props for you to control.
Bootstrap uses jquery in order to implement animation and other changes to the DOM, and React, let's say, does not like that. Long story short - React primarily uses the virtual DOM in order to manipulate the actual DOM. That means that every change to the DOM has to be recorded in the virtual DOM first.
Reactstrap provides prebuilt Bootstrap 4 components that allow a great deal of flexibility and prebuilt validation. This allows us to quickly build beautiful forms that are guaranteed to impress and provide an intuitive user experience.
Bootstrap and reactstrap can be primarily classified as "Front-End Frameworks" tools.
Its core difference is that in React-Bootstrap you are supposed to make your own component (which is technically Bootstrap but uses JSX format, camel case naming convention, etc.). Then you use those components by importing them in App.js.
What are some alternatives to Bootstrap and React? Semantic empowers designers and developers by creating a shared vocabulary for UI. jQuery is a cross-platform JavaScript library designed to simplify the client-side scripting of HTML.
Lots of people use React as the V in MVC. Since React makes no assumptions about the rest of your technology stack, it's easy to try it out on a small feature in an existing project. Bootstrap belongs to "Front-End Frameworks" category of the tech stack, while React can be primarily classified under "Javascript UI Libraries".
The current versions are bootstrap 5.2.0, react-bootstrap 2.5.0 and reactstrap 9.1.3 . bootstrap , The most popular front-end framework for developing responsive, mobile first projects on the web. It was authored by The Bootstrap Authors on Aug, 2011. react-bootstrap , Bootstrap 5 components built with React.
I have been struggling with this myself and it is as @Besart Marku says, highly opinion based.
One thing that did make a diffirence for me is that reactstraps documentation uses state in alot of its code examples:
import React from 'react';
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
class ModalExample extends React.Component {
constructor(props) {
super(props);
this.state = {
modal: false
};
this.toggle = this.toggle.bind(this);
}
toggle() {
this.setState(prevState => ({
modal: !prevState.modal
}));
}
render() {
return (
<div>
<Button color="danger" onClick={this.toggle}>{this.props.buttonLabel}</Button>
<Modal isOpen={this.state.modal} toggle={this.toggle} className={this.props.className}>
<ModalHeader toggle={this.toggle}>Modal title</ModalHeader>
<ModalBody>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={this.toggle}>Do Something</Button>{' '}
<Button color="secondary" onClick={this.toggle}>Cancel</Button>
</ModalFooter>
</Modal>
</div>
);
}
}
export default ModalExample;
vs react-bootstrap uses functions and Hooks:
function MyVerticallyCenteredModal(props) {
return (
<Modal
{...props}
size="lg"
aria-labelledby="contained-modal-title-vcenter"
centered
>
<Modal.Header closeButton>
<Modal.Title id="contained-modal-title-vcenter">
Modal heading
</Modal.Title>
</Modal.Header>
<Modal.Body>
<h4>Centered Modal</h4>
<p>
Cras mattis consectetur purus sit amet fermentum. Cras justo odio,
dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac
consectetur ac, vestibulum at eros.
</p>
</Modal.Body>
<Modal.Footer>
<Button onClick={props.onHide}>Close</Button>
</Modal.Footer>
</Modal>
);
}
function App() {
const [modalShow, setModalShow] = React.useState(false);
return (
<ButtonToolbar>
<Button variant="primary" onClick={() => setModalShow(true)}>
Launch vertically centered modal
</Button>
<MyVerticallyCenteredModal
show={modalShow}
onHide={() => setModalShow(false)}
/>
</ButtonToolbar>
);
}
render(<App />);
Im not giving an answer saying one of these is better than the other,its a preference and for me personaly I vent with reactstrap since I tend to use classcomponents more than Hooks so having finished examples that I can tweak with minimal effort did the trick.
They are 2 different libraries but both based on Bootstrap components.
Some little statistics about them https://www.npmtrends.com/react-bootstrap-vs-reactstrap
Thought I'd add my 2 pence. I came the other way, learning React Native with Android development before moving over to React.
The former method with Reactstrap is closer to how we have done things with Web Development and Bootstrap where as the latter is closer to how I have done things in React Native i.e. component based development.
Its really down to use case both make sense however if you have a dynamic page with lots of moving parts I would suggest using the React-Bootstrap library as the implementation is much closer to the component model and will allow you to make your page elements reusable (not that you can't do that with the former Reactstrap library).
I have gone with Reactstrap for now simply because it offers all of Bootstrap 4 out of the box which is what I need with very little fuss.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With