carbon icon indicating copy to clipboard operation
carbon copied to clipboard

[Datatable] - React: breaking change made to lifecycle

Open Deriohig opened this issue 4 years ago • 2 comments

[Datatable] - React: breaking change made to lifecycle

What package(s) are you using?

  • [ x] carbon-components
  • [ x] carbon-components-react

Detailed description

Since recent changes to the data table competent some of our code no longer works... We are updating our rows dynamically and some of the rows ids may change after a state change... however... when the render method is called by DataTable... the rows that are passed into it are from stale state (since the changes was lifecycle based, changing from willRecieveProps to didUpdate) and contain row ids that were in the previous rows props... the state is updated in the DataTable's componentDidUpdate which runs post-render, when they were previously done in the willRecieveProps (pre render).

Is this issue related to a specific component?

Data table

What did you expect to happen? What happened instead? What would you like to see changed?

Use a pre-render lifecycle method

What browser are you working in?

What version of the Carbon Design System are you using? "carbon-components": "10.15.0", "carbon-components-react": "7.15.0",

What offering/product do you work on? Any pressing ship or release dates we should be aware of?

IBM Security Guardium Insights (November 1st)

Steps to reproduce the issue

contact me on slack for demo

Additional information

  • Screenshots or code
  • Notes

Deriohig avatar Sep 10 '20 16:09 Deriohig

Hi there @Deriohig! 👋

Sorry to hear about the breaking changes, could you provide some steps to reproduce the issue in a codesandbox?

joshblack avatar Sep 11 '20 19:09 joshblack

Hi,

I created a repro for the issue here: repro. If you look at the console output after clicking the "Update rows" button, you will see the DataTable render method being called twice. The first time, the rows supplied to the render method will NOT match the rows supplied as props to the DataTable ( the ids are different ). They would, in fact, be the old data rows. On the second render call, the rows would match.

avainch avatar Sep 14 '20 22:09 avainch

Where are ya'll at with this issue? Is it still happening for you?

sstrubberg avatar Nov 28 '22 16:11 sstrubberg