1

I am trying to render a table from array of object using react-bootstrap-table. This is the code :

render() {
  var products = [{
    id: 1,
    name: "Product1",
    price: 120
  }, {
    id: 2,
    name: "Product2",
    price: 80
  }];

  return (
    <div>
      <BootstrapTable data={products} striped hover>
      </BootstrapTable>
    </div>
  )
}

when I run the application I saw this error :

Uncaught TypeError: Cannot read property 'reduce' of undefined

1 Answer 1

1

the issue is because I did not include

<TableHeaderColumn isKey dataField='id'>Product ID</TableHeaderColumn>

Once I put this line in then the application works fine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.