r/javascript • u/ijkortez • Jun 12 '22
How to use bootstrap in React
https://www.devtip.co/how-to-use-bootstrap-in-react/18
u/SuperSubwoofer Jun 12 '22
Just don’t?
7
u/ijkortez Jun 12 '22
I love that everyone agrees on not to use it. Haha
4
u/SuperSubwoofer Jun 13 '22
Bootstrap does have its place. I just think the more comfortable you get with flexbox and grid, it’s way less necessary.
3
u/b0x3r_ Jun 12 '22
Can you explain why not? I’m just learning web dev and it’s not obvious to me why you wouldn’t
4
u/SuperSubwoofer Jun 13 '22
You can obviously use it, and there’s nothing inherently wrong with it. HOWEVER, as a Front End Dev, using Normalize as a basis and using a mix of Flexbox and CSS grid gives you much granular control.
You can also combine that with CSS variables or a pre-processor like LESS or SASS. My biggest issue with it is once you get into custom client sites, it becomes more of a pain to use then to use your own stylesheets and boilerplates.
3
u/b0x3r_ Jun 13 '22
Thanks! Is it common to use something like sass if you are using a framework like react?
2
u/SuperSubwoofer Jun 13 '22
I’m a WordPress dev, so I use React in a bit of a different capacity, but using a pre processor is agnostic to the framework you are using in my experience. I highly recommend SASS or LESS. It’s more readable and easy to set variables with.
2
u/b0x3r_ Jun 13 '22
I appreciate the advice, there’s so many frameworks out there that’s it difficult as a newcomer to sort out what modern devs are using.
1
u/SuperSubwoofer Jun 13 '22
If you’re completely new, I would recommend vanilla JS, html, and CSS to start then branch into React and pre-processors. You’ll have a solid foundation and learning new frameworks will be much easier.
2
Jun 13 '22
I feel like sass is in a weird place right now because of evolution of css, where it ends up having conflicting functionality and becomes awkward to use. Like css variables vs sass variables and css functions vs sass functions. You end up mixing them together because they don't completely overlap, which ends up looking like a mess, because some of it needs to be compiled by sass and some should be left as is. And you often have to explicitly tell it which is which with #{} and it's just ugly and hard to type.
Even some syntax is now conflicting, for example using / for division is deprecated in favor of a function because css uses it as a parameter separator in more and more functions.
Overall, I think it's not worth the hassle anymore. Things that it does provide like nested selectors and functions/mixins/modules aren't really that useful with a js framework because you are most likely already scoping your css to your components. So I'd say no, you don't really need it.
6
u/Veranova Jun 12 '22
Dogma
There’s nothing wrong with using it, it’s a good quality and popular tool. It might also not be appropriate for your needs. Only you can decide.
Anyone who gives an absolute answer on this kind of thing is just a classic redditor
0
u/SuperSubwoofer Jun 13 '22
There’s nothing wrong with using it, no. My original comment is just an opinion.
But as someone who’s a Front End Dev, it has diminishing returns or can end up being a straight up pain to use.
0
Jun 12 '22
[deleted]
2
u/SuperSubwoofer Jun 13 '22
I elaborated on this above, but as a Front End Developer, it has diminishing returns and using your own stylesheets and a mix of flexbox and CSS grid gives you more granular control over your styles.
If it’s easier to use for you, absolutely go for it. But there’s definitely instances where it’s overkill or a straight up pain.
3
3
2
-6
u/someexgoogler Jun 12 '22
Don't use react
2
2
u/react_dev Jun 12 '22
Username checks out
1
u/someexgoogler Jun 13 '22
I'll expand on my response: also don't use angular. I started writing web apps ten years before I worked at Google.
2
u/seriouslynoideaman Jun 12 '22
Are we ditching react already?
-4
u/someexgoogler Jun 13 '22
I think react has some uses, but I also think it is waaaaay overused. I built one project in react, but I find it idiomatic, bloated, and hard to maintain. In particular, form validation is difficult in react. Of course react has a huge number of followers, but so did jquery and BASIC back in the day.
2
u/react_dev Jun 13 '22
React is a lightweight rendering library. Think of it like jQuery. Form validation has always been hard without two way binding. But there are libraries now like formik that makes it a breeze to work in React.
Say what you want about React but they completely changed the game on how web apps are written. Components, JSX, lifecycle hooks, and one way dataflow made its way to other frameworks and are here to stay.
If you want it to scale better, then create component systems with a tighter interface. React doesn’t hold your hand so it’s easy to write crappy code. But with discipline it’s shown to be extremely effective at scale…. as proven at many companies already.
-1
u/someexgoogler Jun 13 '22
jQuery is nothing like react. jQuery solved a problem at the time to make unified APIs - mostly for Ajax. React is much more invasive.
10
u/[deleted] Jun 12 '22
I'm not a fan of this method. I install bootstrap and import BS to a index.scss and import that file in my app.js