* Remove unused components * Fix company not being created issue * Fix company not being created issue * Fix company not being created issue * Optimize rendering * Optimize rendering
20 lines
575 B
TypeScript
20 lines
575 B
TypeScript
import { useRecoilCallback } from 'recoil';
|
|
|
|
import { tableEntitiesFamilyState } from '@/ui/table/states/tableEntitiesFamilyState';
|
|
|
|
export function useUpsertEntityTableItem() {
|
|
return useRecoilCallback(
|
|
({ set, snapshot }) =>
|
|
<T extends { id: string }>(entity: T) => {
|
|
const currentEntity = snapshot
|
|
.getLoadable(tableEntitiesFamilyState(entity.id))
|
|
.valueOrThrow();
|
|
|
|
if (JSON.stringify(currentEntity) !== JSON.stringify(entity)) {
|
|
set(tableEntitiesFamilyState(entity.id), entity);
|
|
}
|
|
},
|
|
[],
|
|
);
|
|
}
|