question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

insertRow={true} causes Invariant Violation: Objects are not valid as a React child

See original GitHub issue

I have upgraded a React app from 15.6.2 to 16.0.0, and updated react-boostrap-table too.

If my JSX looks like:

<BootstrapTable
   ref="licenceTypesTable"
   insertRow={true}
   data={this.props.licenceTypesData.licenceTypes}
   striped={true} 
   hover={true}
   options={options}
   search={true}
   exportCSV={true}>
      <TableHeaderColumn dataField="id" isKey={true} autoValue={true}>ID</TableHeaderColumn>
      <TableHeaderColumn dataField="title" dataSort={true}>Type</TableHeaderColumn>
</BootstrapTable>

Then it fails to render.

I get this console message:

Invariant Violation: Objects are not valid as a React child (found: object with keys {$$typeof, key, children, containerInfo, implementation}). If you meant to render a collection of children, use an array instead.
    in Modal
    in div
    in ToolBar
    in div
    in div
    in BootstrapTable
    in div
    in div
    in div

If I remove the insertRow attribute, the error goes away, and the component will render again.

I was relying on insertRow to provide UI to add new data, it would be a shame to have to roll my own.

It is helps, licenceTypes is a very simple array:

licenceTypes: [{id:1, title: "MIT"}, {id:2, title: "Apache-2.0"}]

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
silentbobbertcommented, Nov 17, 2017

Hi Allen, I think I was using the latest version - I had been going through all my dependencies and updating them. I will try again and let you know.

0reactions
samdarcy42commented, Apr 24, 2018

I am also experiencing this invariant violation using the 4.3.0 build.

        `    <div>
                <BootstrapTable data={products} insertRow={true} striped>
                <TableHeaderColumn dataField='id' isKey={true}>Product ID</TableHeaderColumn>
                <TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
                <TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
                </BootstrapTable>
            </div>`

Whenever the insertRow property is added I receive the following error:

“Invariant Violation: Modal.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.”

I have copied one of the example tables’ code.

Any assistance is appreciated!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invariant Violation: Objects are not valid as a React child
This error usually happens because a function involved in dispatching an event has been given an unexpected object type (i.e passing an object...
Read more >
Understanding the "Objects are not valid as a react child" Error ...
The problem starts when myVariable assumes an object. React has no way to tell what to render when provided with an object, thus...
Read more >
Invariant Violation: Objects are not valid as a React child
Sometimes you might try to display data in a React application and you might see the following error in the console: Objects are...
Read more >
Resolving Error: "Objects are not valid as a React child"
As the error message states, React cannot render objects as children directly. If you are seeing this error, there is a good chance...
Read more >
Objects are not valid as a React child React error | bobbyhadz
The React.js error "Objects are not valid as a React child" occurs when we try to directly render an object or an array...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found