Duplicate rows in dynamic table

I created a dynamic table on my dashboard page. The issue I am having is that it’s displaying duplicate rows.

On page 3 row “8784” under Issue Id column is duplicate. I print the rows array in console and checked the data it’s showing one record for “8784”.

When navigating pages. It’s added “8784” on other pages and each time I navigate between pages it keeps on add each times.

Steps: Reload the dashboard page and wait until the dynamic table is loaded.
Go to page two. Note "8784: row does not exist on page two.
Go to page three. Note “8784” row is duplicated.
Go to page two. Note “8784” is added at the top.
Go to page one. Note “8784” is added at the top.
Go to page three. Note “8784” is added at the top and two rows from initial load.
Go to page one. Note “8784” is added twice at the top.

Each time I change the page it keeps on adding “8784” row.

See attached pictures.
Initial load page 1:

Initial load page 2:

Initial load page 3:

Navigate to page 2:

Navigate to page 1:

Navigate to page 3:

Navigate to page 2:

Navigate to page 1:

Navigate to page 3 and back to 1: Note: “8784” is showing 3 times.

Below is the code:

return (
    <>
      
      <DynamicTable
        caption={status}
        isLoading={isLoading}
        loadingSpinnerSize="large"
        head={head}
        rows={rows}
        rowsPerPage={15}
        defaultSortKey="issueId"
        emptyView="No data to display"
      />
    </>
  );
for loop {
tableRows.push(
  { key: tsJson.Ticket.JiraKey, cells: [
    { key: tsJson.Ticket.JiraKey + 'k', content: <Link href={jiraUrl} openNewTab="true">{tsJson.Ticket.JiraKey}</Link>},
    { key: tsJson.Ticket.TicketNumber, content: <Link href={tsUrl} openNewTab="true">{tsJson.Ticket.TicketNumber}</Link>},
    { key: tsJson.Ticket.JiraKey + 's', content: jira.summary},
    { key: tsJson.Ticket.JiraKey + 'n', content: jira.status},
    { key: parentKey, content: jira.parentKey },
    { key: parentTitle, content: jira.parentTitle },
 ]});
}

setRows(tableRows);
setStatus(`Total: ${Object.keys(tableRows).length}`);
setIsLoading(false);
console.log(tableRows);

From the console log here is the row data.

{
	"key": "...8784",
	"cells": [
		{
			"key": "...8784k",
			"content": {
				"type": "Link",
				"key": null,
				"ref": null,
				"props": {
					"href": "https://mydomain.atlassian.net/browse/...8784",
					"openNewTab": "true",
					"children": "...8784"
				},
				"_owner": null
			}
		},
		{
			"key": "77...",
			"content": {
				"type": "Link",
				"key": null,
				"ref": null,
				"props": {
					"href": "https://mydomain.teamsupport.com/Ticket.aspx?ticketid=1667...",
					"openNewTab": "true",
					"children": "77... }"
				},
				"_owner": null
			}
		},
		{
			"key": "...8784s",
			"content": "The summay of the jira ticket."
		},
		{
			"key": "...8784n",
			"content": "With Product Owner"
		},
		{
			"key": "",
			"content": ""
		},
		{
			"key": "",
			"content": ""
		}
	]
},

Hey @AhmedPan

My guess is that this is a problem with the logic in your app that’s adding new rows to the table, rather than an issue with the dynamic table itself. But I’m not seeing enough information here to be certain.

I’d have a look more closely at what is causing your loop to run, and add additional data to your tableRows array.

Cheers!
Melissa

I had duplicate rows.

1 Like