Skip to content

getHeadingsFromChildren forces use of string as table cell child #105

@8lane

Description

@8lane

Hi 👋

I'm upgrading to use the v2 beta version on a project and had some issues around the responsive table component. My bad If I'm doing something totally wrong but looks to me like this might be something that could be tweaked.

My table is dynamically created using the react-table library and the table cell values are rendered via a method. This used to work fine in v1, but in v2 due to the responsive changes and more specifically the getHeadingsFromChildren helper, we can no longer use anything other than a string as a child of Table.Cell.

My code:

<Table.Head>
  {headerGroups.map((headerGroup) => {
    const { ...headerGroupProps } = headerGroup.getHeaderGroupProps()
    return (
      <Table.Row {...headerGroupProps} key={headerGroupProps.key}>
        {headerGroup.headers.map((column) => {
          const { ...headerProps } = column.getHeaderProps()
          return (
            <Table.Cell
              {...headerProps}
              key={headerProps.key}
              {column.render('Header')}
            </Table.Cell>
          )
        })}
      </Table.Row>
    )
  })}
</Table.Head>

What gets rendered now:
image

I fixed this for now by importing renderToString from react-dom/server but this isn't an ideal solution

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions