react-tabulator icon indicating copy to clipboard operation
react-tabulator copied to clipboard

targets.row.findCell is not a function

Open HugoP27 opened this issue 2 years ago • 9 comments

targets.row.findCell is not a function

  • bug: when setting table data asynchronously and double clicking on a cell it throws the following error: TypeError targets.row.findCell is not a function

Environment Details

  • react-tabulator version: 0.18.1

Long Description

  • Its like the state doesn't update correctly when setting data asynchronously. It happes in this repo's example sandbox image

Code Sandbox: repo example

Workaround None so far...

HugoP27 avatar May 19 '22 08:05 HugoP27

Checking data before renderer <ReactTabulator /> fixes the bug

{this.state.data.length 
         ? <ReactTabulator columns={this.columns} data={this.state.data} />
         : null}

NikitaK92 avatar Jun 07 '22 12:06 NikitaK92

Checking data before renderer <ReactTabulator /> fixes the bug

{this.state.data.length 
         ? <ReactTabulator columns={this.columns} data={this.state.data} />
         : null}

Is a workaround*

Randy808 avatar Jun 16 '22 18:06 Randy808

@NikitaK92 it works, thanks a lot

HugoP27 avatar Mar 28 '23 19:03 HugoP27

the official code sanbox in the readme file should just be updated to reflect the workaround.

{this.state.data.length > 0 && ( <ReactTabulator columns={this.columns} data={this.state.data} /> )}

HugoP27 avatar Mar 28 '23 19:03 HugoP27

I am facing this issue now.

But I can't use {this.state.data.length > 0 && ( <ReactTabulator columns={this.columns} data={this.state.data} /> )} as my data is set dynamically.

I use ref on the tabulator and set data using setData() method in the useEffect. In this case, how do I solve this error?

Thanks.

SundaramMaheshkumar avatar Apr 19 '23 15:04 SundaramMaheshkumar

I am facing this issue now.

But I can't use {this.state.data.length > 0 && ( <ReactTabulator columns={this.columns} data={this.state.data} /> )} as my data is set dynamically.

I use ref on the tabulator and set data using setData() method in the useEffect. In this case, how do I solve this error?

Thanks.

Hi there,

You just change:

{this.state.data.length > 0 && ( <ReactTabulator columns={this.columns} data={this.state.data} /> )}

To

{ data.length > 0 && ( <ReactTabulator columns={columns} data={data} /> )}

Assuming your state is set up as follows:

const [data, setData] = useState([])

HugoP27 avatar Apr 19 '23 20:04 HugoP27

I am having the same issue. And can't find a way around it. I am checking for the data (tried with .length > 0 as well). It works as expected when cell is edited with one click, but it throws an error on double click.

I even tried making an empty function and pass that to cellDblClick <> {data && columns.current && ( <ReactTabulator events={{ cellEdited: (e) => handleCellEdited(e), cellDblClick: handleDbClick }} key={tableKey} columns={columns.current} data={data} /> )} </>

denisjovic avatar Jun 21 '23 17:06 denisjovic

@denisjovic it seems like support for react tabulator has been discontinued as it was last updated a year and a half ago. So I decided to use the main tabulator library and created a simple component. This works well and can be easily updated when tabulator releases new versions. Sample code attached (example of how to use it at the bottom) Table component.zip

HugoP27 avatar Jun 21 '23 18:06 HugoP27

Awesome, thank you @HugoP27, I will give it a try and report back.

denisjovic avatar Jun 21 '23 20:06 denisjovic