table icon indicating copy to clipboard operation
table copied to clipboard

Filters feature: Cannot read properties of undefined

Open Achaak opened this issue 2 years ago • 1 comments

Describe the bug

Hello,

When I put undefined in the columnFilters state, I have this error image But the typing authorize to put undefined And when I put a empty array, my browser freeze

Your minimal, reproducible example

https://tanstack.com/table/v8/docs/examples/react/filters

Steps to reproduce

Put undefined in the columnFilters state with this example https://tanstack.com/table/v8/docs/examples/react/filters

Expected behavior

Check if columnFilters is undefined or remove undefined typing

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

OS: Windows Browser: Opera

react-table version

8.7.9

TypeScript version

4.9.5

Additional context

No response

Terms & Code of Conduct

  • [X] I agree to follow this project's Code of Conduct
  • [X] 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.

Achaak avatar Feb 03 '23 15:02 Achaak

Hi there, I can confirm this and it also exists in "Table Core" package. The error comes from this line;

https://github.com/TanStack/table/blob/c214ab3680a73d1fbce002430aeb1b73ba10c11d/packages/table-core/src/utils/getFilteredRowModel.ts#L56

It assumes that there are a column filter set, You can bypass this error by setting column filters to empty array in the table state if you intend to use only global filters.

columnFilters: []

ullmark avatar Dec 18 '23 09:12 ullmark