Files
probo/packages/ui/src/Molecules/Table/utils.ts
Jonathan 7e8222d9b5 Fix cubic review
Signed-off-by: Jonathan <contact@grafikart.fr>
2025-12-01 18:23:11 +04:00

19 lines
481 B
TypeScript

export function getKey<T>(item: T): string {
if (
item &&
typeof item === "object" &&
"id" in item &&
(typeof item.id === "string" || typeof item.id === "number")
) {
return item.id.toString();
}
if (typeof item === "string" || typeof item === "number") {
return item.toString();
}
if (item === undefined) {
return "";
}
console.error("Cannot compute a key from item", item);
return "";
}