React table filter type error (.toLowerCase)

ts
<CommandItem
key={option.label}
onSelect={() => {
if (isSelected) {
selectedValues.delete(option.label);
} else {
selectedValues.add(option.label);
}

const filterValues = Array.from(selectedValues);

column?.setFilterValue(
filterValues.length ? filterValues : undefined
);
}}
>
<CommandItem
key={option.label}
onSelect={() => {
if (isSelected) {
selectedValues.delete(option.label);
} else {
selectedValues.add(option.label);
}

const filterValues = Array.from(selectedValues);

column?.setFilterValue(
filterValues.length ? filterValues : undefined
);
}}
>
Im using shadCN's task example
5 Replies
bento
bentoOP2y ago
adding a toString() to the end of filterValues fixes the error but it messes us the filtering as the string eg. 10A is split into "1","0","A"
JacobParis
JacobParis2y ago
If you want to lowercase the elements in your array, use a map instead
filterValues.map(value => value.toLowerCase())
filterValues.map(value => value.toLowerCase())
I don't see in your code example where you're calling toLowerCase but you probably want at the end
column.setFilterValue(filterValues.length
? filterValues.map(value => value.toLowerCase())
: undefined
)
column.setFilterValue(filterValues.length
? filterValues.map(value => value.toLowerCase())
: undefined
)
bento
bentoOP2y ago
to lowercase is being called from react table's getRowModel
bento
bentoOP2y ago
bento
bentoOP2y ago
this doesnt work either... i think its being converted somewhere else
Want results from more Discord servers?
Add your server