I am using react-table to build a sortable list of forms. In this example, each form has a checkbox for approved, a textfield for the name, and a send button. After clicking the send button, the form should be removed from the DOM. The problem is that when removing the first row, the checkbox in the second row takes the state of the first row. The text field maintains its value.
I am using uncontrolled form components to display the data, but I am using the handleChange method to update the top-level data array.
Here is a code sandbox to reproduce the issue. https://codesandbox.io/s/unruffled-williamson-d172s
Repro steps:
- Check the checkbox in the first row.
- Enter some text in the checkbox in the first row.
- Hit send in the first row.
Expected results: The first row should be removed.
Actual results: The first row is removed and the remaining checkbox is checked.
Would anyone be able to explain why the checkbox is checked after removing the first row? I think it might be because the key is based on the index, meaning, after the first row is removed, the second row's key is same as the first row. Is there a way to customize the react-table key? If the key is the reason though, I am confused as to why only the checkbox copies the previous value and not the text box.