You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Default row id is not stable or unique when data is modified #4162
The cell id is meant to be a unique id, but it is based on the indice of the cell in the data representation. What this means is if you move a cell around or modify data by deleting or adding cells then its id changes. Even worst, other cells will inherit the id the cell previously had leading to all sorts of shenanigans in React if it is used as a key. I think the cell id should be made stable and unique such that it can be safely used as a key.
Your minimal, reproducible example
x
Steps to reproduce
x
Expected behavior
x
How often does this bug happen?
No response
Screenshots or Videos
No response
Platform
x
react-table version
8.2.6
TypeScript version
No response
Additional context
No response
Terms & Code of Conduct
I agree to follow this project's Code of Conduct
I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
As far as I know, no IDs in the system are index based other than the default row ID accessor. Can you elaborate a bit more? Maybe link to the source or an example?
I'm sorry I just realized this was an example of me not understanding the docs the first time I read them. getRowId solved my issue.
To be more specific, the issue was that the row id was by default based on its index which causes everything that uses an id as key to be brittle, including the cell id. Maybe the solution here is give a big warning in the docs, but also I wonder if there is interest in having the default row id be more stable to data updates.
To elaborate on my doc experience, what I had done first was go to the the Cell API documentation and read that id was unique and then carried on with my day. I didn't think to look at the Row or Table documentation to read further. 😅
changed the title [-]Cell `id` is not stable or unique when data is modified[/-][+]Default row `id` is not stable or unique when data is modified[/+]on Jul 17, 2022
Yeah I get your sentiment. But we can only know so much about the nature of your data. The alternative of requiring a row id accessor is also not that wonderful. This is the happy medium :)
Activity
tannerlinsley commentedon Jul 17, 2022
As far as I know, no IDs in the system are index based other than the default row ID accessor. Can you elaborate a bit more? Maybe link to the source or an example?
krispya commentedon Jul 17, 2022
I'm sorry I just realized this was an example of me not understanding the docs the first time I read them.
getRowIdsolved my issue.To be more specific, the issue was that the row
idwas by default based on its index which causes everything that uses an id as key to be brittle, including the cellid. Maybe the solution here is give a big warning in the docs, but also I wonder if there is interest in having the default row id be more stable to data updates.To elaborate on my doc experience, what I had done first was go to the the Cell API documentation and read that
idwas unique and then carried on with my day. I didn't think to look at the Row or Table documentation to read further. 😅[-]Cell `id` is not stable or unique when data is modified[/-][+]Default row `id` is not stable or unique when data is modified[/+]tannerlinsley commentedon Jul 17, 2022
Yeah I get your sentiment. But we can only know so much about the nature of your data. The alternative of requiring a row id accessor is also not that wonderful. This is the happy medium :)