Open garryachapman opened 8 years ago
According to Facebook we should not mutate props. Simply remount the table. This is in Accordance with the philosophy laid out by React. On Thu, Feb 11, 2016 at 11:16 AM garryachapman notifications@github.com wrote:
Does a reactTable function exist which allows the data to be updated? In version 3.0.4 the replaceData function no longer exists. Looking at the code I can't find anything which performs a similar function.
— Reply to this email directly or view it on GitHub https://github.com/erfangc/ReactTable/issues/59.
I use ReactTable 3.0.4 with react 0.13.1 to show data that change live (real-time). The problem is, the table displays the intial set of data, but when the data gets updated the table still displays the old data, unless I use a different key for the table every time I update the data.. The following is the code of the render function in the parent component:
render: function() {
var self = this;
var columnDefs = self.props.headerOut.map(function(column) {
return { colTag: column, text: column }
});
return React.createElement(reacttable.ReactTable, {
disablePagination: true,
rowKey: 'id',
data: self.props.dataOut,
height: "700px",
columnDefs: columnDefs,
key: self.state.keyToRefresh
});
}
To make the table update I have to change "self.state.keyToRefresh" every time I get new data. Is it something I do wrong? (P.S. the data has always an "id" property).
Hey
Sorry for the late response. That is a really interesting use case. I have not thought about real time update.
Though if the update freq is seconds (inside of under a second) the theoretical correct way would be to rerender the entire table as the "props", the thing that is supposed to be immutable, changed.
Perhaps I'll address this use case in a more elegant way in my new ES6 table widget giga-grid
On Fri, Apr 29, 2016 at 3:26 AM Andrea Ferrandi notifications@github.com wrote:
I use ReactTable 3.0.4 with react 0.13.1 to show data that change live (real-time). The problem is, the table displays the intial set of data, but when the data gets updated the table still displays the old data, unless I use a different key for the table every time I update the data.. The following is the code of the render function in the parent component:
render: function() { var self = this; var columnDefs = self.props.headerOut.map(function(column) { return { colTag: column, text: column } }); return React.createElement(reacttable.ReactTable, { disablePagination: true, rowKey: 'id', data: self.props.dataOut, height: "700px", columnDefs: columnDefs, key: self.state.keyToRefresh }); }
To make the table update I have to change "self.state.keyToRefresh" every time I get new data. Is it something I do wrong? (P.S. the data has always an "id" property).
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/erfangc/ReactTable/issues/59#issuecomment-215646528
Does a reactTable function exist which allows the data to be updated? In version 3.0.4 the replaceData function no longer exists. Looking at the code I can't find anything which performs a similar function.