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.

Setting state inside rowEvents or using onSelect inside selectRow does not work

See original GitHub issue

Here’s the error in the console:

Uncaught TypeError: Cannot set property 'selected' of undefined at RowSelectionWrapper.componentWillReceiveProps (wrapper.js:64) at callComponentWillReceiveProps (react-dom.development.js:6389) at updateClassInstance (react-dom.development.js:6575) at updateClassComponent (react-dom.development.js:7848) at beginWork (react-dom.development.js:8225) at performUnitOfWork (react-dom.development.js:10224) at workLoop (react-dom.development.js:10288) at HTMLUnknownElement.callCallback (react-dom.development.js:542) at Object.invokeGuardedCallbackDev (react-dom.development.js:581) at invokeGuardedCallback (react-dom.development.js:438) at renderRoot (react-dom.development.js:10366) at performWorkOnRoot (react-dom.development.js:11014) at performWork (react-dom.development.js:10967) at batchedUpdates (react-dom.development.js:11086) at batchedUpdates (react-dom.development.js:2330) at dispatchEvent (react-dom.development.js:3421)

Here’s how my function is called: ( Logging the state inside rowEvents actually prints out the state so it’s not a scope issue )

class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      selectedRow: {}
    };
  }
  ...
  render(){
    const rowEvents = {
      onClick: (e, row, rowIndex) => {
        this.setState({ selectedRow: row });
      }
    };

  return(
 <BootstrapTable
          keyField="id"
          data={tableData}
          columns={columns}
          rowEvents={rowEvents}
          pagination={paginationFactory()}
          filter={filterFactory()}
          selectRow={selectRow}
          striped
          hover
          condensed
          />
       )
   }
}

The same error pops up when you add onSelect to selectRow and handle the event with another function

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
grogicommented, Mar 12, 2018

@karanbajaj2209 The 0.1.3 seems fine.

0reactions
Northshootcommented, Mar 31, 2018

I am getting the same error while using 0.15 version when updating via state.selected

wrapper.js:64 Uncaught TypeError: Cannot set property 'selected' of undefined
    at RowSelectionWrapper.componentWillReceiveProps (wrapper.js:64)
    at callComponentWillReceiveProps (react-dom.development.js:6389)
    at updateClassInstance (react-dom.development.js:6575)
    at updateClassComponent (react-dom.development.js:7848)
    at beginWork (react-dom.development.js:8225)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Assign object {row} to state - react bootstrap table
I'm trying to migrate my application which currently uses react-bootstrap-table to react-bootstrap-table-next but I'm having a problem. What I ...
Read more >
Row Selection Props · react-bootstrap-table2
This callback function will be called when a row is select/unselect and pass following four arguments: row , isSelect , rowIndex and e...
Read more >
React Table Checkbox
Configure Checkbox component from material-ui library. How to work with checkboxes in React Storing and Reading the checkbox state. react-bootstrap-table2 ...
Read more >
React Table Checkbox - ITALCOLLAUDI
Using setState with React Checkbox onChange In React, the best way to do this is via ... If specified width is not working...
Read more >
React Table Checkbox - Azienda Roberto e Nicola Ercolani
Using setState with React Checkbox onChange In React, the best way to do ... How to work with checkboxes in React Storing and...
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