`defaultCanSort` not setting canSort to false in columns
See original GitHub issueI set the defaultCanSort
option as described in the docs:
const {
getTableProps,
getTableBodyProps,
headerGroups,
rows,
prepareRow
} = useTable(
{
columns,
data,
defaultCanSort: false
},
useSortBy
);
Unfortunately when logging columns
, they all still return canSort: true
, which means some of my unsortable headers are all styled as sortable.
Example
As you can see below, the columns marked ‘sortable’ are receiving canSort
as true, even though defaultCanSort
is set to false and names
is the only column with canSort
set.
https://codesandbox.io/s/flamboyant-chebyshev-ksdy3
**Expected behavior **
Setting defaultCanSort
to false
in the options object should mean all columns are marked as canSort
false by default.
- OS: OSX
- Browser: Firefox
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
defaultCanSort not setting canSort to false in columns #2080
Setting defaultCanSort to false in the options object should mean all columns are marked as canSort false by default. OS: OSX; Browser: Firefox....
Read more >How to do default sorting in react-table - Stack Overflow
In order to sort a column (or columns) when the table is built, you just have to set the sortBy array on the...
Read more >Sorting | TanStack Table Docs
Set to true for sorting toggles on this column to start in the descending direction. enableSorting. tsx. enableSorting?: boolean.
Read more >Sorting Feature Guide - Material React Table Docs
Sorting can be disabled globally by setting the enableSorting prop to false . This will disable sorting for all columns. You can also...
Read more >react-table@7.7.0 - Bundle Scanner
nThis usually means you need to need to name your plugin hook by setting the ... getFirstDefined(defaultCanSort, defaultColumnCanSort, false); column.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The docs need to be more clear here maybe, but that default only applied to columns without accessors. If a column has an accessor, you will need to set
canSort
on the column or even extend the default column options so all columns havecanSort: false
I have a similar issue, in my case I had to set
canSort: true
on the column but this is not covered by Typescript definitions so had to hack it in. Be good if the documentation and types could be updated.