New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-fuzzysort

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-fuzzysort

🔎 [The Fuzzysort library](https://github.com/farzher/fuzzysort) implemented as a handy React component

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

React Fuzzysort

🔎 The Fuzzysort library implemented as a handy React component

Installation

npm install react-fuzzysort
# or
yarn add react-fuzzysort

Basic Usage

import { Search } from 'react-fuzzysort';

function Catalogue() {
  const input = useRef<HTMLInputElement>(null);

  return (
    <Wrapper>
      <SearchBar ref={input} />
      <Search
        input={input}
        fallback={<FallbackText>No results!</FallbackText>}
        list={[
          { query: 'carrot', node: <Item>🥕 Carrot</Item> },
          { query: 'banana', node: <Item>🍌 Banana</Item> },
          { query: 'ketchup', node: <Item>🍅 Ketchup</Item> },
          // and so on...
        ]}
      />
    </Wrapper>
  );
}

Work Smarter By Mapping!

const list = ['🥕 Carrot', '🍌 Banana', '🍅 Ketchup'];

return (
  <Search
    list={list.map((listItem) => ({
      query: listItem,
      node: <Item>{listItem}</Item>,
    }))}
  />
);

Documentation

Info: documentation is temporarily available in the README while my website undergoes construction

Configuration Options

These are passed down as props to the Search component.

list

  • A list of items to be searched from
  • This is an array of objects (SearchItem[])
  • Search items includes:
    • query: the string that is compared against the input value
    • node: the thing that is rendered

input

  • A React ref to the search input

fallback

  • The fallback that is rendered when there are no results

debounce

  • A debounce time avoids excessive rerenders
  • By default, it is 0 which has proven to be fine for a couple thousand items

onFirstItemChange

  • Fires when the first item in the list changes
  • Does not fire on mount

onNoResults

  • Fires when there are no results
  • Does not fire when there are no results multiple times in a row

keyOptions

Changelogs

v1.0.1

  • Fixed several issues with package.json

v1.0.0

  • Added React Fuzzysort

FAQs

Package last updated on 18 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts