my jsx file successfully recognizes the react-bootstrap elements but there's no styling to them. my project's node-modules folder contains both react-bootstrap and bootstrap. why is this happening?
var React = require('react');
var Button = require('react-bootstrap').Button;
var Jumbotron = require('react-bootstrap').Jumbotron;
var ReactComponentHi = React.createClass({displayName: 'Hi',
render: function() {
return (
<div>
<Button bsStyle='success'>
clickk
</Button>
<Jumbotron>
<h1>Hello, world!</h1>
<p>This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
<p><Button bsStyle='primary'>Learn more</Button></p>
</Jumbotron>
</div>
);
}
});
module.exports = ReactComponentHi;
How to Use Bootstrap with React? 1 1. Using Bootstrap CDN. This is one of the easiest ways to use bootstrap in your React app. The best thing about bootstrap CDN is no requirement for ... 2 2. Import Bootstrap as a Dependency. 3 3. Install React Bootstrap Package.
With react-bootstrap, the table element can be overridden using the custom CSS classes, but before using the table, you need to import it. After importing the table element and bootstrap CSS, create the basic table. In the above render () function, <Table> elements uses the header and body section along with the combination of rows and columns.
If it doesn't, most probably the issue is that you haven't set your webpack to use a CSS loader. If you've installed the CSS just for your particular project, you can access it (by putting the following in index.js): import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
In case your application needs JavaScript components along with the bootstrap, then at the bottom of the page place <script> tag, just before the closing </body> tag. These snippets will be added to the public/index.html page.
i added the following line to my index.html and it worked.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
Actually, importing directly from the CDN is not needed, it's better to import the css from your local dist folder, to ensure the versions are the same.
Add this to your index.js / index.tsx below your other imports:
import 'bootstrap/dist/css/bootstrap.min.css';
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