1.0.1 • Published 6 months ago
@pawan9303/react-search v1.0.1
@pawan9303/react-search
A simple utility for searching through arrays of strings or numbers in React applications. Case-insensitive search functionality.
🚀 Features
- Case-insensitive search
- Filters array based on a search query
- Ideal for use in React applications
📦 Installation
npm install @pawan9303/react-search📚 Usage
import search from '@pawan9303/react-search';
const items = ['apple', 'banana', 'orange', 'apple pie'];
// Search for "apple"
const result = search(items, 'apple');
console.log(result);
// Output: [ 'apple', 'apple pie' ]🔧 API Reference
search(list, query)
| Param | Type | Description |
|---|---|---|
list | Array | The array to search through |
query | Qurey | The search query (case-insensitive) |
✅ Example
import React, { useState } from 'react';
import search from '@pawan9303/react-search';
const SearchExample = () => {
const [query, setQuery] = useState('');
const items = ['apple', 'banana', 'orange', 'apple pie'];
const handleSearch = (e) => {
setQuery(e.target.value);
};
const filteredItems = search(items, query);
return (
<div>
<input
type="text"
placeholder="Search..."
value={query}
onChange={handleSearch}
/>
<ul>
{filteredItems.map((item, index) => (
<li key={index}>{item}</li>
))}
</ul>
</div>
);
};
export default SearchExample;👨💻 Author
Made by @pawan9303
📄 License
What's Included:
- Installation instructions.
- Usage examples (both simple search and React component usage).
- API reference for the search function.
- Author info and license details.
Now all the information you requested is neatly packed in a single markdown file.
1.0.1
6 months ago