1.0.0 • Published 3 years ago

react-incremental-search v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

incremental-searchbox-react-component

Search with a keyword and some of the closest results (using fuzzy search) will show.

demo

NPM JavaScript Style Guide

Install

npm install --save incremental-search

Usage

With React Component

import React, { Component } from 'react'

import IncrementalSearchBox from 'incremental-search'
import 'incremental-search/dist/index.css'

class Example extends Component {
  render() {
    return <IncrementalSearchBox />
  }
}

With React hooks

import React, { useState } from 'react'
import IncrementalSearchBox from 'incremental-search'

export default function App() {
  const [selectedOption, setSelectedOption] = useState(null)
  const [coins, setCoins] = React.useState([])

  return (
    <div className='App'>
      <IncrementalSearchBox
        options={coins}
        dataKey='name'
        style={undefined}
        onSelect={setSelectedOption}
      />
    </div>
  )
}

Running Example in Local

demo

npm start

open a different tab

cd example
npm start

License

MIT © yuriko627