I found some similar questions like this and this. But my problem is somewhat different. I'm polling data for table every second from my REST Api with axios. I need is the user to freely manipulate (i.e. order, sort and select) the rows when data updates. In general, when there is data update, all selections are removed and orders are lost.
I've created a local store with my data which I pass as a reference to my table and update it like this:
setStrategies(newStrategies) {
if (this.state.strategies.length == 0) {
newStrategies.forEach(strategy => {
this.state.strategies.push(strategy)
});
} else {
this.state.strategies.forEach(strategy => {
var newStrategy = newStrategies.find(x => x.strategyName === strategy.strategyName);
strategy.status = newStrategy.status;
strategy.lastPingTime = newStrategy.lastPingTime;
});
}
It works but I think it's overcomplicated. So could you tell me what is the best approach or may be table-component that could do binding automaticaly?