# react-use-fuzzy

> React hook for client side fuzzy search using Fuse.js

Latest version **1.0.4** (published 2019-12-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-use-fuzzy
pnpm add react-use-fuzzy
yarn add react-use-fuzzy
bun add react-use-fuzzy
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2019-12-10 |
| First published | 2019-12-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Joshua Tonga |
| Maintainers | joshuatonga |
| Keywords | react, hooks, fuzzy, fuzzy-search, fuse.js, client-search |

## Links

- npm: https://www.npmjs.com/package/react-use-fuzzy
- Homepage: https://github.com/hellojoshuatonga/react-use-fuzzy#readme
- npm.io page: https://npm.io/package/react-use-fuzzy

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2019-12-10
- 1.0.3 — 2019-12-10
- 1.0.2 — 2019-12-10
- 1.0.1 — 2019-12-09
- 1.0.0 — 2019-12-09
- 0.0.5 — 2019-12-09
- 0.0.4 — 2019-12-09
- 0.0.3 — 2019-12-09
- 0.0.2 — 2019-12-09

## README

# react-use-fuzzy

[![NPM version](https://img.shields.io/npm/v/react-use-fuzzy.svg?style=flat-square)](https://npmjs.org/package/react-use-fuzzy)
[![Build Status](https://img.shields.io/travis/hellojoshuatonga/react-use-fuzzy/master.svg?style=flat-square)](https://travis-ci.org/hellojoshuatonga/react-use-fuzzy)
[![Coverage Status](https://img.shields.io/codecov/c/github/hellojoshuatonga/react-use-fuzzy/master.svg?style=flat-square)](https://codecov.io/gh/hellojoshuatonga/react-use-fuzzy/branch/master)

A react hook in Typescript for client side fuzzy search using [Fuse.js](https://github.com/krisk/fuse).

## 🚀  Install
```bash
$ npm install --save react-use-fuzzy
```

## 🎈 Usage
```typescript
import React, { useState } from 'react';
import { useFuzzy } from 'react-use-fuzzy';
import './App.css';

interface Product {
  id: number;
  name: string;
}

interface ProductItemProps {
  product: Product;
}

const ProductItem: React.FC<ProductItemProps> = ({ product }) => {
  return <li>{product.name}</li>;
}

interface ProductsListProps {
  products: Product[];
}

const ProductsList: React.FC<ProductsListProps> = ({ products }) => {
  return (
    <ul>
    {
      products.map((product) => (
        <ProductItem key={product.id} product={product} />
      ))
    }
    </ul>
  )
}

const App: React.FC = () => {
  const productsData: Product[] = [
    {
      id: 1,
      name: 'T-shirt',
    },
    {
      id: 2,
      name: 'Short',
    },
  ]
  const [products, setProducts] = useState<Product[]>(productsData);

  const { result, keyword, search } = useFuzzy<Product>(products, {
    keys: ['name'],
  });

  return (
    <div className='App'>
      <header className='App-header'>
        <input
          type='text'
          placeholder='Search products'
          value={keyword}
          onChange={(e) => search(e.target.value)}
          />
        <ProductsList products={result} />
      </header>
    </div>
  );
}

export default App;
```

## ⛓️ Peer Dependencies
- [React](https://www.npmjs.com/package/react) (16.x.x)
- [Fuse.js](https://www.npmjs.com/package/fuse.js/v/3.4.3) (3.x.x)

## 🎉 Acknowledgements
- Inspired by [react-use-fuse](https://github.com/MartinL83/react-use-fuse) Fuse.js wrapper.


## License
MIT ©

---
_Source: https://npm.io/package/react-use-fuzzy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
