React Bootstrap table not formatting












0















I am very new to react and am attempting to follow a basic table tutorial: (http://allenfang.github.io/react-bootstrap-table/example.html#basic)



I have installed react-bootstrap-table




npm install react-bootstrap-table --save




I have imported bootstrap-table




import {BootstrapTable, TableHeaderColumn} from
'react-bootstrap-table';




I have imported the css file:




import
'../../node_modules/react-bootstrap-table/dist/react-bootstrap-table-all.min.css';




With the above I am expecting a table to display as below:
enter image description here



However what I am seeing with my code is:



enter image description here



Why isn't the table appearing as in the example?



import React, { Component } from "react";
import './MenuButton.css';
import './MenuContainer.css';
import MenuButton from './MenuButton';
import Menu from './Menu';
import serverCall from "../api/ServerCall";
import {BootstrapTable,TableHeaderColumn} from 'react-bootstrap-table';
import '../../node_modules/react-bootstrap-table/css/react-bootstrap-table.css'


class MenuContainer extends Component {

constructor(props, context) {
super(props, context);
this.state = {
visible: false
};
this.handleMouseDown = this.handleMouseDown.bind(this);
this.toggleMenu = this.toggleMenu.bind(this);

this.getCustomers();
}

handleMouseDown(e) {
this.toggleMenu();
e.stopPropagation();
}

toggleMenu() {
this.setState({
visible: !this.state.visible
});
}

getCustomers(){
console.log("Getting Customers");
serverCall(function(error, response) {
if (error) {
alert("Authorization Failed.")
} else {
console.log(response);

}
},"","customers.php");
}

render() {


let products = [{
id: 1,
name: "Item name 1",
price: 100
},{
id: 2,
name: "Item name 2",
price: 100
}];

return (

<div>
<div className="menu-container">
<div className="grid-item-hamburger-menu">
<MenuButton handleMouseDown={this.handleMouseDown}/>
<Menu handleMouseDown={this.handleMouseDown} menuVisibility={this.state.visible}/>
</div>

<div className="grid-item-dashboard-title">
Dashboard | Customers
</div>

<div className="grid-item-search">
</div>

<div className="grid-item-table">

<BootstrapTable data={ products }>
<TableHeaderColumn dataField='id' isKey>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
<TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
</BootstrapTable>
</div>
</div>
</div>
);
}
}

export default MenuContainer;









share|improve this question



























    0















    I am very new to react and am attempting to follow a basic table tutorial: (http://allenfang.github.io/react-bootstrap-table/example.html#basic)



    I have installed react-bootstrap-table




    npm install react-bootstrap-table --save




    I have imported bootstrap-table




    import {BootstrapTable, TableHeaderColumn} from
    'react-bootstrap-table';




    I have imported the css file:




    import
    '../../node_modules/react-bootstrap-table/dist/react-bootstrap-table-all.min.css';




    With the above I am expecting a table to display as below:
    enter image description here



    However what I am seeing with my code is:



    enter image description here



    Why isn't the table appearing as in the example?



    import React, { Component } from "react";
    import './MenuButton.css';
    import './MenuContainer.css';
    import MenuButton from './MenuButton';
    import Menu from './Menu';
    import serverCall from "../api/ServerCall";
    import {BootstrapTable,TableHeaderColumn} from 'react-bootstrap-table';
    import '../../node_modules/react-bootstrap-table/css/react-bootstrap-table.css'


    class MenuContainer extends Component {

    constructor(props, context) {
    super(props, context);
    this.state = {
    visible: false
    };
    this.handleMouseDown = this.handleMouseDown.bind(this);
    this.toggleMenu = this.toggleMenu.bind(this);

    this.getCustomers();
    }

    handleMouseDown(e) {
    this.toggleMenu();
    e.stopPropagation();
    }

    toggleMenu() {
    this.setState({
    visible: !this.state.visible
    });
    }

    getCustomers(){
    console.log("Getting Customers");
    serverCall(function(error, response) {
    if (error) {
    alert("Authorization Failed.")
    } else {
    console.log(response);

    }
    },"","customers.php");
    }

    render() {


    let products = [{
    id: 1,
    name: "Item name 1",
    price: 100
    },{
    id: 2,
    name: "Item name 2",
    price: 100
    }];

    return (

    <div>
    <div className="menu-container">
    <div className="grid-item-hamburger-menu">
    <MenuButton handleMouseDown={this.handleMouseDown}/>
    <Menu handleMouseDown={this.handleMouseDown} menuVisibility={this.state.visible}/>
    </div>

    <div className="grid-item-dashboard-title">
    Dashboard | Customers
    </div>

    <div className="grid-item-search">
    </div>

    <div className="grid-item-table">

    <BootstrapTable data={ products }>
    <TableHeaderColumn dataField='id' isKey>Product ID</TableHeaderColumn>
    <TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
    <TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
    </BootstrapTable>
    </div>
    </div>
    </div>
    );
    }
    }

    export default MenuContainer;









    share|improve this question

























      0












      0








      0








      I am very new to react and am attempting to follow a basic table tutorial: (http://allenfang.github.io/react-bootstrap-table/example.html#basic)



      I have installed react-bootstrap-table




      npm install react-bootstrap-table --save




      I have imported bootstrap-table




      import {BootstrapTable, TableHeaderColumn} from
      'react-bootstrap-table';




      I have imported the css file:




      import
      '../../node_modules/react-bootstrap-table/dist/react-bootstrap-table-all.min.css';




      With the above I am expecting a table to display as below:
      enter image description here



      However what I am seeing with my code is:



      enter image description here



      Why isn't the table appearing as in the example?



      import React, { Component } from "react";
      import './MenuButton.css';
      import './MenuContainer.css';
      import MenuButton from './MenuButton';
      import Menu from './Menu';
      import serverCall from "../api/ServerCall";
      import {BootstrapTable,TableHeaderColumn} from 'react-bootstrap-table';
      import '../../node_modules/react-bootstrap-table/css/react-bootstrap-table.css'


      class MenuContainer extends Component {

      constructor(props, context) {
      super(props, context);
      this.state = {
      visible: false
      };
      this.handleMouseDown = this.handleMouseDown.bind(this);
      this.toggleMenu = this.toggleMenu.bind(this);

      this.getCustomers();
      }

      handleMouseDown(e) {
      this.toggleMenu();
      e.stopPropagation();
      }

      toggleMenu() {
      this.setState({
      visible: !this.state.visible
      });
      }

      getCustomers(){
      console.log("Getting Customers");
      serverCall(function(error, response) {
      if (error) {
      alert("Authorization Failed.")
      } else {
      console.log(response);

      }
      },"","customers.php");
      }

      render() {


      let products = [{
      id: 1,
      name: "Item name 1",
      price: 100
      },{
      id: 2,
      name: "Item name 2",
      price: 100
      }];

      return (

      <div>
      <div className="menu-container">
      <div className="grid-item-hamburger-menu">
      <MenuButton handleMouseDown={this.handleMouseDown}/>
      <Menu handleMouseDown={this.handleMouseDown} menuVisibility={this.state.visible}/>
      </div>

      <div className="grid-item-dashboard-title">
      Dashboard | Customers
      </div>

      <div className="grid-item-search">
      </div>

      <div className="grid-item-table">

      <BootstrapTable data={ products }>
      <TableHeaderColumn dataField='id' isKey>Product ID</TableHeaderColumn>
      <TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
      <TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
      </BootstrapTable>
      </div>
      </div>
      </div>
      );
      }
      }

      export default MenuContainer;









      share|improve this question














      I am very new to react and am attempting to follow a basic table tutorial: (http://allenfang.github.io/react-bootstrap-table/example.html#basic)



      I have installed react-bootstrap-table




      npm install react-bootstrap-table --save




      I have imported bootstrap-table




      import {BootstrapTable, TableHeaderColumn} from
      'react-bootstrap-table';




      I have imported the css file:




      import
      '../../node_modules/react-bootstrap-table/dist/react-bootstrap-table-all.min.css';




      With the above I am expecting a table to display as below:
      enter image description here



      However what I am seeing with my code is:



      enter image description here



      Why isn't the table appearing as in the example?



      import React, { Component } from "react";
      import './MenuButton.css';
      import './MenuContainer.css';
      import MenuButton from './MenuButton';
      import Menu from './Menu';
      import serverCall from "../api/ServerCall";
      import {BootstrapTable,TableHeaderColumn} from 'react-bootstrap-table';
      import '../../node_modules/react-bootstrap-table/css/react-bootstrap-table.css'


      class MenuContainer extends Component {

      constructor(props, context) {
      super(props, context);
      this.state = {
      visible: false
      };
      this.handleMouseDown = this.handleMouseDown.bind(this);
      this.toggleMenu = this.toggleMenu.bind(this);

      this.getCustomers();
      }

      handleMouseDown(e) {
      this.toggleMenu();
      e.stopPropagation();
      }

      toggleMenu() {
      this.setState({
      visible: !this.state.visible
      });
      }

      getCustomers(){
      console.log("Getting Customers");
      serverCall(function(error, response) {
      if (error) {
      alert("Authorization Failed.")
      } else {
      console.log(response);

      }
      },"","customers.php");
      }

      render() {


      let products = [{
      id: 1,
      name: "Item name 1",
      price: 100
      },{
      id: 2,
      name: "Item name 2",
      price: 100
      }];

      return (

      <div>
      <div className="menu-container">
      <div className="grid-item-hamburger-menu">
      <MenuButton handleMouseDown={this.handleMouseDown}/>
      <Menu handleMouseDown={this.handleMouseDown} menuVisibility={this.state.visible}/>
      </div>

      <div className="grid-item-dashboard-title">
      Dashboard | Customers
      </div>

      <div className="grid-item-search">
      </div>

      <div className="grid-item-table">

      <BootstrapTable data={ products }>
      <TableHeaderColumn dataField='id' isKey>Product ID</TableHeaderColumn>
      <TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
      <TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
      </BootstrapTable>
      </div>
      </div>
      </div>
      );
      }
      }

      export default MenuContainer;






      reactjs bootstrap-4






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 '18 at 10:46









      MattBlackMattBlack

      85021329




      85021329
























          1 Answer
          1






          active

          oldest

          votes


















          0














          try this line
          import '../../node_modules/react-bootstrap-table/css/react-bootstrap-table.css'
          in main entry components






          share|improve this answer
























          • Hi I added that line in index.js and still no change

            – MattBlack
            Nov 22 '18 at 11:14











          • actually you were correct! thank you for your help!

            – MattBlack
            Nov 22 '18 at 11:39











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53429205%2freact-bootstrap-table-not-formatting%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          try this line
          import '../../node_modules/react-bootstrap-table/css/react-bootstrap-table.css'
          in main entry components






          share|improve this answer
























          • Hi I added that line in index.js and still no change

            – MattBlack
            Nov 22 '18 at 11:14











          • actually you were correct! thank you for your help!

            – MattBlack
            Nov 22 '18 at 11:39
















          0














          try this line
          import '../../node_modules/react-bootstrap-table/css/react-bootstrap-table.css'
          in main entry components






          share|improve this answer
























          • Hi I added that line in index.js and still no change

            – MattBlack
            Nov 22 '18 at 11:14











          • actually you were correct! thank you for your help!

            – MattBlack
            Nov 22 '18 at 11:39














          0












          0








          0







          try this line
          import '../../node_modules/react-bootstrap-table/css/react-bootstrap-table.css'
          in main entry components






          share|improve this answer













          try this line
          import '../../node_modules/react-bootstrap-table/css/react-bootstrap-table.css'
          in main entry components







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 22 '18 at 10:57









          Bikram MaharjanBikram Maharjan

          625




          625













          • Hi I added that line in index.js and still no change

            – MattBlack
            Nov 22 '18 at 11:14











          • actually you were correct! thank you for your help!

            – MattBlack
            Nov 22 '18 at 11:39



















          • Hi I added that line in index.js and still no change

            – MattBlack
            Nov 22 '18 at 11:14











          • actually you were correct! thank you for your help!

            – MattBlack
            Nov 22 '18 at 11:39

















          Hi I added that line in index.js and still no change

          – MattBlack
          Nov 22 '18 at 11:14





          Hi I added that line in index.js and still no change

          – MattBlack
          Nov 22 '18 at 11:14













          actually you were correct! thank you for your help!

          – MattBlack
          Nov 22 '18 at 11:39





          actually you were correct! thank you for your help!

          – MattBlack
          Nov 22 '18 at 11:39




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53429205%2freact-bootstrap-table-not-formatting%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          Origin of the phrase “under your belt”?