react-bootstrap-table2: Table not updating when formatter is setted
My column setting are these:
columns = {
dataField: 'inexistentField',
text: "Obj state",
formatter: (cell, obj) => {
console.log('Obj -> ', obj); // Only executed when on table change function is executed by table
}
}
Table does not update when I call my tableChange function (one that is passed down to onTableChange) externally (not using one of the page buttons).
When I click on any sortable column, content generated by formatter function changes normally. If data changes a lot (for instance, with different number of elements) table works fine. I’ve debugged with React Dev Tools and my state and table props are correct.
Version bootstrap-table: 1.3.0
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 22 (6 by maintainers)
How could I define dinamyc data on one column? For instance, given a value in one of my obj’s field, show a specific icon? Because if
formattercan’t manage dinamyc data andformatExtraDatadoesn’t receive the current row, I have no idea how we could solve a problem like that one.Thanks in advance
@jkrawczyk What is not documented yet is that the grid needs you to treat the data as immutable, much like redux requires. This way it knows what to redraw, etc. I have modified your example not to directly mutate state and it works as expected. https://github.com/react-bootstrap-table/react-bootstrap-table2/issues/656#issuecomment-443488050
https://codesandbox.io/s/v8pz48rl30