react-fuzzy is a React component that provides a customizable fuzzy search input field and results dropdown. It enables developers to integrate powerful fuzzy search capabilities into their React applications with minimal setup, abstracting away the underlying search logic. The current stable version is 1.3.1, which includes compatibility updates for React 17 and 18. The package demonstrates a moderate release cadence, with minor updates addressing new features, bug fixes, and peer dependency compatibility. Key differentiators include extensive customization options for the UI (via `resultsTemplate`, `inputProps`, and various style props) and the ability to configure the underlying fuzzy search algorithm parameters like `threshold`, `distance`, and `keys` to search within specific object properties.
npm install react-fuzzyVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of the FuzzySearch component with a predefined list of objects, including state management for selected items and an example of a custom result template for enhanced UI.
Update any legacy string refs in your codebase to modern React ref patterns if you were previously relying on them in conjunction with this library or if your React version demands it.
Always provide an `onSelect` prop that updates your component's local state or performs a side effect with the `newSelectedItem` argument.
Refer to the `resultsTemplate` example in the documentation or quickstart to correctly implement custom rendering, paying attention to `styles.selectedResultStyle`, `styles.resultsStyle`, and `clickHandler`.
Ensure your project's React version is compatible with the `react-fuzzy` peer dependencies, ideally React 17 or 18. Address any peer dependency warnings during installation.
If users are expected to type very long queries, consider increasing the `maxPatternLength` prop, but be mindful of performance implications, especially with large datasets.
Ensure the `list` prop is always an array of objects, even if empty, before passing it to `FuzzySearch`.
Reduce the search query length or increase the `maxPatternLength` prop in your `FuzzySearch` component (default is 32).
If you need to listen to input changes, use the `onInput` prop directly on the `FuzzySearch` component instead of nesting it within `inputProps`.
Ensure `resultsTemplate` is a function that accepts `(props, state, styles, clickHandler)` as arguments and returns JSX.