A table doesn't get updated when a defaultColumn changes
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 28.4k
- Forks
- 3.6k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 10
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided CodeSandbox and the useReactTable configuration, reproducing the change from an initial defaultColumn size of 200 to 50. Read the column sizing implementation and compare how defaultColumn changes are handled with columnResizeDirection; done means rendered table columns reflect the updated default size.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100