After getting a project setup in rails 5.1 with --webpack=react option should I install the bootstrap gem? or use yarn add bootstrap? Or would I need both if I'm using rails and react components throughout a project?
Also, are there pros and cons of either method?
It depends on where you want to use Bootstrap.
In the case you need it, in a app/views/*/*.html.erb
for instance, you would need the gem, and require it in the Rails assets pipeline in the app/assets/stylesheets/application.scss
and same for JavaScript file.
But as you mentioned you created your Rails application with --webpack=react
, I guess you'd like to use Bootstrap in your client side application, so the app/javascript
folder and not the Rails assets (app/assets
).
In this case you will have to install it using yarn
.
You have to see the app/assets
as the "old way", or the non-javascript framework way (which isn't fully true as you have some gems to install React or AngularJs etc...), and you should see app/javascript
the new way, with webpacker, so using a JavaScript framework and being an app 100% JavaScript (while in the assets you'll use some .erb
files).
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