Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: e.values[t] is undefined #147

Open
MarvinKlar opened this issue Feb 12, 2024 · 0 comments
Open

TypeError: e.values[t] is undefined #147

MarvinKlar opened this issue Feb 12, 2024 · 0 comments

Comments

@MarvinKlar
Copy link

I am using the useFilters component and got the following error:

TypeError: e.values[t] is undefined
    ye filterTypes.js:43
    ye filterTypes.js:43
    ye filterTypes.js:42
    a useFilters.js:225
    n useFilters.js:197
    w useFilters.js:256
    React 2
    Pe useFilters.js:185
    v publicUtils.js:91
    v publicUtils.js:90
    useTable useTable.js:331
    _u basic.table.js:175
    React 8
    unstable_runWithPriority scheduler.production.min.js:18
    React 10
    unstable_runWithPriority scheduler.production.min.js:18
    React 3
[character:13024:25](https://XXXXXXXXXXXX/character)
    overrideMethod character:13024
    React 5
    unstable_runWithPriority scheduler.production.min.js:18
    React 4
    unstable_runWithPriority scheduler.production.min.js:18
    React 10
    unstable_runWithPriority scheduler.production.min.js:18
    React 3
    
Uncaught TypeError: e.values[t] is undefined
    ye filterTypes.js:43
    ye filterTypes.js:43
    ye filterTypes.js:42
    a useFilters.js:225
    n useFilters.js:197
    w useFilters.js:256
    React 2
    Pe useFilters.js:185
    v publicUtils.js:91
    v publicUtils.js:90
    useTable useTable.js:331
    _u basic.table.js:175
    React 8
    unstable_runWithPriority scheduler.production.min.js:18
    React 10
    unstable_runWithPriority scheduler.production.min.js:18
    React 3
[filterTypes.js:43:20](https://XXXXXXXXXXXX/static/node_modules/react-table/src/filterTypes.js)
    ye filterTypes.js:43
    some self-hosted:137
    ye filterTypes.js:43
    filter self-hosted:241
    ye filterTypes.js:42
    a useFilters.js:225
    reduce self-hosted:263
    n useFilters.js:197
    w useFilters.js:256
    React 2
    Pe useFilters.js:185
    v publicUtils.js:91
    forEach self-hosted:203
    v publicUtils.js:90
    useTable useTable.js:331
    _u basic.table.js:175
    React 8
    unstable_runWithPriority scheduler.production.min.js:18
    React 10
    unstable_runWithPriority scheduler.production.min.js:18
    React 3
    receiveMessage SelectChild.sys.mjs:265
    receiveMessage SelectChild.sys.mjs:495

I am using the filter like so:

    const {
        getTableProps,
        getTableBodyProps,
        headerGroups,
        rows,
        prepareRow,
        page,
        canPreviousPage,
        canNextPage,
        pageOptions,
        pageCount,
        gotoPage,
        nextPage,
        previousPage,
        setPageSize,
        state: { pageIndex, pageSize },
        state,
        preGlobalFilteredRows,
        setGlobalFilter,
    } = useTable(
        {
            columns,
            data,
            defaultColumn,
            initialState: { pageIndex: 0, pageSize: 10 },
        },
        useFilters,
        useGlobalFilter,
        useSortBy,
        usePagination,
    )

The error was caused by that SelectColumnFilter:

export function SelectColumnFilter({
    column: { filterValue, setFilter, preFilteredRows, id },
  }) {
    const options = React.useMemo(() => {
      const options = new Set()
      preFilteredRows.forEach(row => {
        options.add(row.values[id])
      })
      return [...options.values()]
    }, [id, preFilteredRows])
  
    return (
      <select
        value={filterValue}
        onChange={e => {
          setFilter(e.target.value || undefined)
        }}
        className="form-control"
      >
        <option value="">Alle</option>
        {options.map((option, i) => (
          <option key={i} value={option}>
            {option}
          </option>
        ))}
      </select>
    )
}

How would I solve this error? Thanks for your help in advance! If you need more information, please let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant