Skip to content

A table doesn't get updated when a defaultColumn changes聽#5275

Open

Description

@anszan

Describe the bug

I used one of your examples and added a defaultColumn with an initial size to the table, which works fine. However if the defaultColumn gets updated later on, this change doesn't get reflected in the actual size of the table columns.
So if we have the below code and I set the initial size to 100 and then in the useEffect I update it to 50, it will still remain 100 for the rendered table even if the table generated by the useReactTable gets the new value. I checked the same with columnResizeDirection and it works fine.

const [defaultColumn, setDefaultColumn] = React.useState({size: 200})

  React.useEffect(() => {
    setDefaultColumn({size: 50})
  }, [])

  const table = useReactTable({
    data,
    columns,
    columnResizeMode,
    defaultColumn,
    columnResizeDirection,
    getCoreRowModel: getCoreRowModel(),
    debugTable: true,
    debugHeaders: true,
    debugColumns: true,
  })

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/reacttable-lycjfh

Steps to reproduce

As in description

Expected behavior

The size of the columns gets updated when the defaultColumn gets changed

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

macOS Chrome

react-table version

8.11.6

TypeScript version

4.4.2

Additional context

No response

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

Activity

  1. anszan commented on Jan 17, 2024

    @anszan
    Author

    Actually I found a different way of handling it, however, it is still a bit confusing that we can modify the value of a defaultColumn but it is reflected in the rendered table, while the other props like e.g. columnResizeDirection affect the rendered table.

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