Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-bootstrap not working as expected

I am trying to use react-bootstrap to style a web page.

package.json

{
  "name": "chrome-ui",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.0.0",
    "react-dom": "^16.0.0",
    "react-scripts": "1.0.16"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "devDependencies": {
    "react-bootstrap": "^0.31.5"
  }
}

App.js

import React from 'react';
import { Button } from 'react-bootstrap'

function CheckState(props){
    function handleClick(e){
        console.log(props.state)
    }
    return(
        <Button bsStyle="primary" onClick={handleClick}>Click for state</Button>
    )
}

However this is what I'm seeing on the web page when I refresh:

enter image description here

It doesn't look like the styling is being added. What am I doing wrong?

like image 972
Morgan Allen Avatar asked Nov 01 '17 19:11

Morgan Allen


2 Answers

Add import "bootstrap/dist/css/bootstrap.css"; in your index.js

like image 69
Nayanajith Avatar answered Sep 29 '22 07:09

Nayanajith


In your react application, open index.js file and add import 'bootstrap/dist/css/bootstrap.css';

like image 35
Victor Bruce Avatar answered Sep 29 '22 08:09

Victor Bruce