diff --git a/apps/builder/src/components/TableList.tsx b/apps/builder/src/components/TableList.tsx index 89d2ef55b..7f1a8f8d6 100644 --- a/apps/builder/src/components/TableList.tsx +++ b/apps/builder/src/components/TableList.tsx @@ -44,7 +44,8 @@ export const TableList = ({ onItemsChange, }: Props) => { const [items, setItems] = useState( - initialItems ?? (hasDefaultItem ? ([defaultItem] as ItemWithId[]) : []) + addIdsIfMissing(initialItems) ?? + (hasDefaultItem ? ([defaultItem] as ItemWithId[]) : []) ) const [showDeleteIndex, setShowDeleteIndex] = useState(null) @@ -183,3 +184,9 @@ export const TableList = ({ ) } + +const addIdsIfMissing = (items?: T[]): ItemWithId[] | undefined => + items?.map((item) => ({ + id: createId(), + ...item, + }))