Skip to content

React-table not updating data #4965

Answered by wb-ts
suriya619 asked this question in Show and tell
Discussion options

You must be logged in to vote

To resolve this issue, you can modify your code as follows:

  1. Remove the selectingMenu state from the Table component and replace it with a new state called selectedRowId. Initialize it with an empty string.

  2. Update the handleMenu function to set the selectedRowId state instead of the selectingMenu state.

const handleMenu = (cell: any) => {
  console.log(cell, 'celldd');
  setSelectedRowId(cell.row.id);
};
  1. Replace the condition in the more column's Cell component to check if the row's id matches the selectedRowId state value.
{
  row.row.id === selectedRowId && <DropdownMenu />
}

With these modifications, the selectedRowId state will be correctly updated when clicking the "more" icon…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by suriya619
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants