Setting state inside rowEvents or using onSelect inside selectRow does not work
See original GitHub issueHere’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:
- Created 6 years ago
- Reactions:4
- Comments:8 (2 by maintainers)
@karanbajaj2209 The 0.1.3 seems fine.
I am getting the same error while using 0.15 version when updating via state.selected