table: column.getSortByToggleProps is not a function
Using v6? No
Using v7? Yes
Describe the bug
When trying to use the return value of column.getSortByToggleProps as an argument to column.getHeadProps(), a Type error occurs stating that column.getSortByToggleProps is not a function
Expected behavior The function should be a property of column, since it is being used in some of the examples.
Screenshots

Desktop (please complete the following information):
- OS: Mac
- Browser: Chrome
- Version: 10.14.5
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 22
Commits related to this issue
- fix: table errors — committed to wildangunawan/headquarter by wildangunawan 2 years ago
- fix: set column type to any to enable TS to compile — committed to wildangunawan/headquarter by wildangunawan 2 years ago
I ran into the same issue but noticed that I had simply misplaced
useSortByin theuseTableparameters like thisBut it should be like this
Hope this helps.
Hey Tanner, I figured out the issue. I wasnāt included the useSortBy inside of the useTable hook.
So basically the acceptable fix for this incompatibility with types is to force the compiler to ignore them? That doesnāt sound like a good idea.
A workaround would be to change the interface of column to any.
Sorry for reopening this issue but Iām facing the same problem. https://gist.github.com/GunB/73d32ff41992e434aee2f50c1d5a4756 Iām using āreact-tableā: ā^7.7.0ā with typescript. Using ā@types/react-tableā: ā^7.7.11ā to reach the types needed. Am I doing something wrong? Iām new to this library
And if I use the soltion given at https://github.com/TanStack/react-table/issues/2970#issuecomment-756364081 then this happensā¦
I am getting the same error.
I know this is old, however I am getting the exact same error and I have actually included the useSortBy inside of the useTable hook.
I get āProperty āgetSortByTogglePropsā does not exist on type āHeaderGroup<object>āā
This prop remains hidden even after having used the useSortBy hook. Is there a solution for this.
I worked on react-table 7.8.0 and was facing the same issue: column.getSortByToggleProps() is not function of HeaderGroup.
But I resolved it using below code, and it works in correct order.
Pass type any inside the map of element headerGroup.headers.map((column: any ) => ()
Issue persists
All the Developer friends who are facing issue with respect to ācolumn.getSortByToggleProps is not a functionā
I would like to tell you that, check your useTable functions argument structure. If you are calling useTable as
Then you will get this error. Itās a silly mistake, but yes, itās important. Rather, useSortBy should be called outside the curly braces as follows
Also, please check from where are you importing useSortBy, is it from āreact-tableā or something else.
I think this should solve the problem for people without Typescript. For Typescript Developers, (column: any) will be required
Hope finally this issue is resolved with this fixes
Same issue , getSortByToggleProps is not available in column . In my case I have used useSortBy as recommended on docs
@tannerlinsley - I would love to understand what the issue is.