Reputation:
I've just created a new project with react cli and installed npm bootstrap.
npm install bootstrap --save
I have then tried bootstrap in App.js:
import React, { Component } from 'react';
import './App.css';
class App extends Component {
render() {
return (
<div>
<div className="container">
<h1>It Works!</h1>
</div>
</div>
);
}
}
export default App;
but it's not working.
This is my package.json:
{
"name": "myapp",
"version": "0.1.0",
"private": true,
"dependencies": {
"bootstrap": "^3.3.7",
"react": "^15.5.4",
"react-dom": "^15.5.4"
},
"devDependencies": {
"react-scripts": "1.0.7"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
Here is my index.html:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1>
<title>React App</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
Is there anything else that I need to do in order to make it work?
Upvotes: 4
Views: 11752
Reputation: 1782
You installed the bootstrap
npm module, but that only downloads the files to your node_modules/
directory. You haven't yet actually required bootstrap within your project itself.
Try doing this above import './App.css'
import 'bootstrap/dist/css/bootstrap.css';
You could also try linking to the bootstrap.min.css
file in your public/index.html
, if the import does not work.
Upvotes: 12