bugfix: use row id instead of index to keep row selection after table… (#120)
* bugfix: use row id instead of index to keep row selection after table update * bugfix: await creation before displaying the row and refetching
This commit is contained in:
@ -124,6 +124,7 @@ const Table = <TData extends { id: string }, SortField>(
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
enableRowSelection: true,
|
||||
onRowSelectionChange: setInternalRowSelection,
|
||||
getRowId: (row) => row.id,
|
||||
});
|
||||
|
||||
const selectedRows = table.getSelectedRowModel().rows;
|
||||
|
||||
@ -63,7 +63,7 @@ function People() {
|
||||
}
|
||||
}, [loading, setInternalData, data]);
|
||||
|
||||
const addEmptyRow = useCallback(() => {
|
||||
const addEmptyRow = useCallback(async () => {
|
||||
const newCompany: Person = {
|
||||
id: uuidv4(),
|
||||
firstname: '',
|
||||
@ -75,7 +75,7 @@ function People() {
|
||||
creationDate: new Date(),
|
||||
city: '',
|
||||
};
|
||||
insertPerson(newCompany);
|
||||
await insertPerson(newCompany);
|
||||
setInternalData([newCompany, ...internalData]);
|
||||
refetch();
|
||||
}, [internalData, setInternalData, refetch]);
|
||||
|
||||
Reference in New Issue
Block a user