React-bootstrap-table2: Second table does not rerender with updated date after setState called

Created on 27 Feb 2019  路  6Comments  路  Source: react-bootstrap-table/react-bootstrap-table2

I have two tables. If I refresh an element in one table, the second table doesn't show the update after setState has been called.

https://codesandbox.io/s/1v8znzknm7

Is there a way to force all tables to re-render?

Most helpful comment

The ones facing same difficulties about the issue, please just follow @AllenFang link provided. It says that you must update the table data array using .map . check example below

```
updateTableRow(array, target_index, form) {
return array.map((item, index) => {
if (index == target_index) {
// This is the item we care about - lets replace it with updated data
return form;
}

  // Otherwise, this is other rows we do not want - keep it as-is
  return item;
})

}
```

All 6 comments

@functionsonly this is not a bug, you mutate the state directly. Please do not modify the state data.

here is an article to teach how to mutate data in a correct way.

Updated with a copy of the state data. Still no render: https://codesandbox.io/s/73zp4z5jk1

Nevermind, I see what you're saying! Thanks.

馃憤

The ones facing same difficulties about the issue, please just follow @AllenFang link provided. It says that you must update the table data array using .map . check example below

```
updateTableRow(array, target_index, form) {
return array.map((item, index) => {
if (index == target_index) {
// This is the item we care about - lets replace it with updated data
return form;
}

  // Otherwise, this is other rows we do not want - keep it as-is
  return item;
})

}
```

@matteusbarbosa Oh man.. Should have raised this post up. It is so helpful for implementing an add, edit or delete button with form like this:
Screenshot 2020-07-22 at 7 05 06 PM

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nskiro picture nskiro  路  4Comments

eylonronen picture eylonronen  路  3Comments

Randore picture Randore  路  3Comments

dillobird picture dillobird  路  3Comments

epsyan picture epsyan  路  4Comments