@@ -21,7 +21,7 @@ interface UpdateRowOutput {
2121export function useUpdateRow (
2222 setData : Dispatch < SetStateAction < GenericRowData [ ] > > ,
2323) {
24- const { tableId } = useTableContext ( )
24+ const { tableId, tableColumns } = useTableContext ( )
2525 const [ rowsUpdating , setRowsUpdating ] = useState < Record < string , boolean > > ( { } )
2626
2727 const [ updateRowMutation ] = useMutation < UpdateRowOutput , UpdateRowInput > (
@@ -45,6 +45,12 @@ export function useUpdateRow(
4545 const updateRow = useCallback (
4646 async ( updatedRow : GenericRowData ) => {
4747 const { rowId, ...data } = updatedRow
48+ // delete keys from data that are not in the table (recently deleted columns)
49+ Object . keys ( data ) . forEach ( ( key ) => {
50+ if ( ! tableColumns . some ( ( column ) => column . id === key ) ) {
51+ delete data [ key ]
52+ }
53+ } )
4854 setRowsUpdating ( ( oldState ) => {
4955 oldState [ rowId ] = true
5056 return { ...oldState }
@@ -64,7 +70,7 @@ export function useUpdateRow(
6470 } ,
6571 } )
6672 } ,
67- [ setData , tableId , updateRowMutation ] ,
73+ [ setData , tableId , tableColumns , updateRowMutation ] ,
6874 )
6975 return {
7076 rowsUpdating,
0 commit comments