Ant Design Table vs. Data Items: Ensuring Unique rowKey Without Public Exposure?
24K reputation · 16 Dec 2020, 15:47 UTC
In Ant Design Table, the rowKey prop is mandatory for stable rendering. The default key is the string 'key', so data objects without a key property cause React to reuse the same key for every row.
This silent failure generates duplicate key warnings, unstable row ordering, and can expose sensitive identifiers if the key is derived from a private field. The documentation states that rowKey is required but offers no guidance for non‑unique or absent values, leaving developers to choose ad‑hoc solutions such as the array index.
Using the index breaks selection, sorting, and editing when the dataset changes, yet it is the most common workaround. The lack of a clear fallback or error handling creates an unresolved decision point for developers who need to avoid accidental public exposure.
What strategies can be employed to guarantee unique rowKey values without leaking sensitive data? How should Ant Design evolve its Table component to provide a safe default or validation mechanism when rowKey is missing or non‑unique? Are there recommended patterns for generating deterministic keys that remain stable across reorders yet remain internal?