Skip to content

Table component bugs — falsy values lost, runtime crash when columns missing, class typo, and unstable keys #614

@mukeshdhadhariya

Description

@mukeshdhadhariya

This PR fixes multiple issues in next-cloudinary/docs/components/Table/Table.js:

  • Preserve falsy values (like 0 and empty string) in cells by only replacing null/undefined.
  • Add default fallbacks for columns and data to avoid runtime crashes.
  • Guard usage of columns in tbody.
  • Fix Tailwind class typo last pr-0 -> last:pr-0.
  • Avoid variable shadowing by renaming column index variable to colIndex.
  • Use stable row keys (row.id ?? rowIndex) instead of just rowIndex.

Testing:

  • Render table with data containing 0 and ensure 0 displays.
  • Render component with columns undefined and some data and ensure no runtime error.
  • Verify header / cell spacing respects last:pr-0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions