All Projects → MartinL83 → react-use-fuse

MartinL83 / react-use-fuse

Licence: MIT license
A tiny wrapper for the fuzzy-search library Fuse.js using React Hooks

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-use-fuse

ozPanel
daha tanıdık bir görüntüde directAdmin teması
Stars: ✭ 13 (-56.67%)
Mutual labels:  fusejs

react-use-fuse

A tiny wrapper for the fuzzy-search library Fuse.js using React Hooks.

https://www.npmjs.com/package/react-use-fuse

Example usage

const customers = [
    {id: 1, name: 'Customer A', email: '[email protected]'},
    {id: 2, name: 'Customer B' email: '[email protected]'}
]

function MyComponent({customers}){

    // This is Fuse specific options. Read more at
    // https://fusejs.io/#examples
    const options = {
        keys: ["name", "email"]
    }

    // Setup the Hook.
    const { result, search, term, reset } = useFuse({
        data: customers,
        options
    });

    return (
        <div>
            <input
                onChange={e => search(e.target.value)}
                value={term}
                placeholder="Search for a customer..."
            />

            {result.map(customer => (
                <div>
                    {customer.name} - {customer.email}
                </div>
            ))}
        </div>
    )
}

<MyComponent customers={customers} />
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].