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.

Rows are modified with a new property tableData

See original GitHub issue

Describe the bug Might be related to #269 as I have exactly the same pb. When rendering rows in the grid, the property tableData is added to every row. This is a big problem with redux as its state MUST never be changed. Therefore, issue mentioning a readonly property may come from the fact that immutability frameworks like immer lock objects from the state for them not to be amended afterwards (as redux demands reducers and components to be pure).

To Reproduce render a list of value in the grid

Expected behavior at the moment, before the rendering, business objects are directly manipulated by adding a tableData metadata on them:

{
  ...businessRow,
  tableData:{
    id:0
  }
}

what may be better instead would be to keep on behaving this way by default, but to permit to get the identifier from the row. If such an option is given, then, instead of getting/setting this “tableData” on the row itself, it can be recovered from a dictionary that is stored in the state.

This way, the input business row is never touched and stored as is in the object that is used by the rendered, and as a sibling property you have all the useful metadata for the rendering purpose.

As ideally, react component should be pure (not modifying its properties), this amendment would help a lot, at moreover it would permit your grid to work with react in any situation.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:20 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
cyberprodigycommented, Feb 10, 2020

Same here, material table seems to be incompatible with immer. I guess material table should not mutate original state anyways

2reactions
GalumphingCalloohcommented, Sep 10, 2020

Ha! This issue might have cost me a job interview in a demo project, but the good news is that I have a fix for this in my local branch. I’ve used ES6 Symbols to decorate the data object with a [tableData] symbol that’s only used internally in material-table. To support older browsers I’ve also included a polyfill. Let me submit a pull, give me a little time to clean up & check it as I was fixing it haphazardly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot add property tableData, object is not extensible - Stack ...
... try to copy your api data to a new array of objects so material-table can modify them, e.g: const editable = rows.map(o...
Read more >
Set or change table properties - Microsoft Support
To set or change table options in Word or Outlook, right-click a table and choose Table Properties. Note: If you want to set...
Read more >
6.4. Returning Data from Modified Rows - PostgreSQL
Sometimes it is useful to obtain data from modified rows while they are being manipulated. The INSERT , UPDATE , and DELETE commands...
Read more >
Google Docs: Working with Tables - GCFGlobal
A table is a grid of cells arranged into rows and columns. ... learn how to create a blank table, modify an existing...
Read more >
<tr>: The Table Row element - HTML - MDN Web Docs - Mozilla
The HTML element defines a row of cells in a table. The row's cells can then be ... Instead, add the CSS vertical-align...
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