question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No rerender when updating data

See original GitHub issue

I have a table of objects this.state.rows to be rendered into an interactive data table that allows user to modify a certain field. When user clicks on a row, my custom dialog will show up and ask information. When user accepte it, I modify the data by this.setState({rows: newRows}). The problem is no rerender occurs and the table remains unchanged.

Expected Behavior

The table updates as new data is pushed into.

Current Behavior

The table remains unchanged.

Steps to Reproduce (for bugs)

I simplify the step of showing dialog and mutating data. Just click the button “Change data” and all values of the first column will be appended “1”. https://codesandbox.io/s/yjv1o52o7z

Your Environment

Tech Version
Material-UI 3.9.3
MUI-datatables 2.1.0
React 16.8.6
browser Firefox 66.0.5 64bits

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
gabrielliwerantcommented, May 16, 2019

You can use it that way if you want, and actually, you may not even need to use updateValue, because the render function will be integrated with the table, so it should trigger the state updates you’re looking for.

You can experiment with this example, that makes updates to the data directly in the “Delete” button: https://github.com/gregnb/mui-datatables/blob/master/examples/custom-action-columns/index.js. If you modify that code to change all the rows, it should also work.

Another experiment you can try is with the customToolbar which will let you add buttons and functions that impact the overall table data.

0reactions
gabrielliwerantcommented, Dec 2, 2019

@HeavenlyEntity, @perfectstrong It’s possible that your issue is the way you are attempting to update state. You may have an object reference issue. I describe that class of mistake here https://github.com/gregnb/mui-datatables/issues/1082.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React re-render not showing updated state array
I am updating state in this manner as event handler function is not having access to latest state values. console.log(state) shows updated state ......
Read more >
React re-renders guide: everything, all at once - Developer way
Re-render happens when React needs to update the app with some new data. Usually, this happens as a result of a user interacting...
Read more >
Learn how to force react components to rerender without ...
A complete guide on component re-rendering. Here you will learn how to force react components to rerender without calling the set state.
Read more >
When does React re-render components? - Felix Gerschau
React re-render explained. React is known for providing a fast user experience by only updating the parts of the UI that have changed....
Read more >
How to Update Data Without Rerendering an Entire Grid in ...
Rerendering an entire Angular grid to updating a single record is very inefficient, and at times it can cause glitches due to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found