Skip to content

Warning: Encountered two children with the same key, undefined. Keys should be unique. #808

Closed

Description

@dangkhoa99

material-react-table version

v2.0.4

react & react-dom versions

v18.2.0

Describe the bug and the steps to reproduce it

When the table is loaded. I see warnings in browser console: Warning: Encountered two children with the same key, undefined. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.

When I remove isLoading in state of table. Browser console is not warning. I think animation skeleton of rows error.

Minimal, Reproducible Example - (Optional, but Recommended)

  const table = useMaterialReactTable({
    columns,
    data,
    rowCount: data.length || 0,
    getRowId: (row, index) => {
      console.log('[row]', index)
      return `${row?.id}` || `${index}`
    },
    // ref
    rowVirtualizerInstanceRef: rowVirtualizerInstanceRef,
    // State
    initialState: { density: 'compact', showGlobalFilter: true },
    state: {
      rowSelection,
      density,
      sorting,
      showProgressBars: isFetching,
      isLoading: isWindowLoading || isLoading,
    })

Screenshots or Videos (Optional)

image

Do you intend to try to help solve this bug with your own PR?

None

Terms

  • I understand that if my bug cannot be reliably reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

Activity

  1. superdweebie commented on Nov 15, 2023

    @superdweebie

    I'm seeing the same bug.

  2. KevinVandy commented on Nov 16, 2023

    @KevinVandy
    Owner

    I'm seeing the same bug.

    This almost always caused by you accidentally not providing a truly unique row id in getRowId

  3. dangkhoa99 commented on Nov 16, 2023

    @dangkhoa99
    ContributorAuthor

    I'm seeing the same bug.

    This almost always caused by you accidentally not providing a truly unique row id in getRowId

    Can you check this issue? I have a unique id for each row but when I assign isLoading from FETCH API to the table's state. I get an undefined warning. I think it's because the table's Skeleton is error.

    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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