Skip to content

Migrate to v3 from v2

tbleckert edited this page Jan 29, 2021 · 1 revision

The v3 release comes with a lot of refactoring and rethinking, code simplifications as well as API simplifications. The goal of react-select-search will always be to be as small as possible in terms of file size and package cost.

The focus for the v3 release was primarily to fix some tree shaking problems and to get rid of unnecessary code. The result was a release with lots of bugfixes and code improvements. We went from 3.5kb minzipped to 3.1kb minzipped + fully shakeable.

Regarding the code and API, the only breaking change is the way fuzzy search was handled.

The fuse option has been removed

The fuse option was removed in favor of the filterOptions callback. Filtering options is now (almost) unopinionated. You can now add your own filtering function or use a default one we have ready for you, powered by fuse.js.

import SelectSearch, { fuzzySearch } from 'react-select-search';
....
<SelectSearch search filterOptions={fuzzySearch} />

Or use your own:

const filterOptions = (options) => (q) => options.filter((o) => o.name === q);

<SelectSearch
    search
    filterOptions={filterOptions}
/>
Clone this wiki locally