A table doesn't get updated when a defaultColumn changes聽#5275
Copy link
Copy link
Open
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
anszan commentedon Jan 17, 2024
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.