Since create-react-app hides Webpack config without having to use eject
, if I want to use something like reactstrap or react-bootstrap, should I eject or will I be fine without ejecting?
Just curious as to what point one would decide when they need to eject
in order to use what they need? At this point in my app, I am merely prototyping, but it will go further with more dependencies and whatnot.
When using create-react-app, you don't need to eject or edit webpack config for using react-bootstrap.
Install react-bootstrap
You have to import css separately by adding this to the top of your
src/index.js
Check out the documentation for using react-bootstrap.
Most dependencies can be added without changing webpack config. You can add packages and start using them.
If you're really concerned about the possibility of changing webpack config, I'd urge you to checkout roadhog. It's a configurable alternative of create-react-app
It's easier now with the latest version of bootstrap: https://getbootstrap.com/docs/4.1/getting-started/webpack/
Install bootstrap and dependencies:
Then in your app entry point (
index.js
) import bootstrap and the css:Good to go!
There is a project called 'reactstrap' https://reactstrap.github.io/ which has all the steps you need to integrate Bootstrap with React
Import Bootstrap CSS in the src/index.js file:
Import required reactstrap components within src/App.js file or your custom component files:
First off, install bootstrap's latest version in your application.
Note: jQuery and popper.js are the dependencies of bootstrap.
In index.js in your root directory and add the below line
In webpack.config.dev.js(Look for plugins and add the below code)
So It would look like this.