fix(FE): fixing table flickering when input form value

This commit is contained in:
randy-ar
2025-11-19 10:21:59 +07:00
parent a9bdb6c36e
commit f68e59e8c7
4 changed files with 183 additions and 49 deletions
@@ -10,7 +10,7 @@ import {
formatVechicleNumber,
} from '@/lib/helper';
import { Icon } from '@iconify/react';
import { useMemo, useState } from 'react';
import { useMemo, useRef, useState } from 'react';
import * as TanStack from '@tanstack/react-table';
import CheckboxInput from '@/components/input/CheckboxInput';
@@ -35,6 +35,9 @@ const SalesOrderProductTable = ({
onBulkDelete,
onAddProductClick,
}: SalesOrderProductTableProps) => {
const onDeleteRef = useRef(onDelete);
onDeleteRef.current = onDelete;
const columns = useMemo(
() => [
{
@@ -114,9 +117,9 @@ const SalesOrderProductTable = ({
<Button
color='error'
className='p-1'
onClick={() => {
onDelete(props.row.original.id as number);
}}
onClick={() =>
onDeleteRef.current(props.row.original.id as number)
}
type='button'
>
<Icon icon='mdi:trash' width={16} height={16} />
@@ -125,7 +128,7 @@ const SalesOrderProductTable = ({
),
},
],
[onDelete]
[]
);
return (