johnbangla
johnbangla

Reputation: 11

Attempted import error: 'match-sorter' does not contain a default export (imported as 'matchSorter')?

enter image description here

a.Attempted import error: 'match-sorter' does not contain a default export (imported as 'matchSorter'). b.ERROR in ./node_modules/crypto-extra/dist/encryption.js 11:31-48 Module not found: Error: Can't resolve 'crypto' in 'G:\react\tmth\node_modules\crypto-extra\dist' c.BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.

Upvotes: 1

Views: 593

Answers (1)

Priya Singh
Priya Singh

Reputation: 11

I was facing similar issue. Accroding to tanstack docs: *This is happening because the package does not export a matchSorter function.

Instead, the package exports three functions: compareItems, rankItem, and rankings. These functions can be used to implement custom sorting and ranking logic.*

If you just want to sort the data, you can use compareItems functions to first compare and then determine the order:

example:

import { compareItems } from '@tanstack/match-sorter-utils';

const data = [...]; // your data array

data.sort((a, b) => compareItems(a, b, ['name', 'age'])); // sort by name and then age
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js"></script>

Upvotes: 0

Related Questions