Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-bootstrap tabs - content is not showing

tabs not showing content and there is no style on tabs

the tabs are not showing content, here is the code. how can i solve this?

what am i doing wrong?

this code is almost similar to the one on react-bootstrap page

//simple tabs.js

import React, {Component} from 'react';
import {Tabs, Tab} from 'react-bootstrap';
import TabItem from './TabItem';
import data from './data'

class SimpleTabs extends Component{

    constructor(props){
        super(props);
        this.state = {
            key: 1 | props.activeKey
        }
        this.handleSelect = this.handleSelect.bind(this);
    }

    handleSelect (key) {
        console.log("selected " + key);
        this.setState({key})
    }
    render(){
        return (
             <Tabs
            activeKey={this.state.key}
            onSelect={this.handleSelect}
            id="controlled-tab-example"
            >
                <Tab eventKey={1} title="Tab 1">
                Tab 1 content
                </Tab>
                <Tab eventKey={2} title="Tab 2">
                Tab 2 content
                </Tab>
                <Tab eventKey={3} title="Tab 3">
                Tab 3 content
                </Tab>
            </Tabs>
        );
    }
}

export default SimpleTabs;

// App.js
import React, { Component } from 'react';
import './App.css';
import 'bootstrap/dist/css/bootstrap.min.css';
import SimpleTabs from './components/SimpleTabs';
import 'bootstrap/dist/js/bootstrap.bundle.min';
import 'bootstrap/dist/css/bootstrap.css'

class App extends Component {
  render() {
    return (
      <SimpleTabs />
    );
  }
}

export default App;

page on web

I do need help to keep moving forward

like image 288
Blaise Iradukunda Avatar asked Nov 18 '22 04:11

Blaise Iradukunda


1 Answers

The problem is your css isn't loading for the bootstrap components. If you add this in the header of your index.html where your serving your React app it should look correct. I see that you are trying to add the min.css to the App. Not sure why that isn't working, but this will work.

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
like image 83
Bradey Whitlock Avatar answered Dec 04 '22 13:12

Bradey Whitlock