-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
104 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v3 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,75 @@ | ||
## React Search Hook | ||
<p align="center"> | ||
|
||
<a href="https://codecov.io/gh/react-search-hook"> | ||
<img src="https://codecov.io/gh/react-search-hook/branch/master/graph/badge.svg?token=H188T7PXLL"/> | ||
</a> | ||
<a href="https://www.npmjs.com/package/react-search-hook"> | ||
<img src="https://img.shields.io/npm/v/react-search-hook.svg?logo=npm" alt="Test Suites"> | ||
</a> | ||
<a href="https://bundlephobia.com/result?p=react-search-hook"> | ||
<img src="https://img.shields.io/bundlephobia/minzip/react-search-hook?style=flat-square" alt="Test Suites"> | ||
</a> | ||
<a href="https://github.com/DevAnsar/react-search-hook/blob/main/LICENSE"> | ||
<img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg" alt="Test Suites"> | ||
</a> | ||
<a> | ||
<img src="https://img.shields.io/npm/types/react-search-hook" alt="Test Suites"> | ||
</a> | ||
|
||
</p> | ||
|
||
## Introduction | ||
|
||
**React Search Hook** is a light library for React, with which you can store the search text in the Store and use it in other components. | ||
|
||
It is production-ready, and gives you the following: | ||
|
||
- 📦 Very lightweight | ||
- 🔧 Easy to use | ||
- ⚛️ Build for React JS | ||
- ⌨️ Highly typed and written in `TypeScript` | ||
|
||
## Documentation | ||
|
||
### 1. Install | ||
|
||
npm | ||
|
||
npm i react-search-hook | ||
|
||
yarn | ||
|
||
yarn add react-search-hook | ||
|
||
### 2. Add provider to top of your component tree | ||
|
||
```jsx | ||
import { SearchProvider } from 'react-search-hook' | ||
function App() { | ||
return <SearchProvider stores={['products',...]}>{children}</SearchProvider> | ||
} | ||
``` | ||
|
||
#### notice that `SearchProvider` needs an array of strings to make stores | ||
|
||
### 3. Simply you can import useSearch hook everywere | ||
|
||
```jsx | ||
import { useSearch } from 'react-search-hook' | ||
function MyExampleComponent() { | ||
const { search, setSearch } = useSearch('products') | ||
|
||
return ( | ||
<div className='Search-box'> | ||
<input value={search} onChange={(e) => setSearch(e.target.value)} /> | ||
<span>{search}</span> | ||
</div> | ||
) | ||
} | ||
``` | ||
|
||
#### notice that `useSearch` needs the store name | ||
|
||
## Contributor ✨ | ||
|
||
[![Contributors](https://contrib.rocks/image?repo=DevAnsar/react-search-hook)](https://github.com/DevAnsar/react-search-hook/graphs/contributors) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
import typescript from "rollup-plugin-typescript2"; | ||
import resolve from "@rollup/plugin-node-resolve"; | ||
import commonjs from "@rollup/plugin-commonjs"; | ||
import terser from "@rollup/plugin-terser"; | ||
import filesize from "rollup-plugin-filesize"; | ||
import peerDepsExternal from "rollup-plugin-peer-deps-external"; | ||
import typescript from 'rollup-plugin-typescript2' | ||
import resolve from '@rollup/plugin-node-resolve' | ||
import commonjs from '@rollup/plugin-commonjs' | ||
import terser from '@rollup/plugin-terser' | ||
import filesize from 'rollup-plugin-filesize' | ||
import peerDepsExternal from 'rollup-plugin-peer-deps-external' | ||
|
||
export default [ | ||
{ | ||
input: "src/index.ts", | ||
input: 'src/index.tsx', | ||
output: [ | ||
{ | ||
dir: "dist", | ||
format: "esm", | ||
dir: 'dist', | ||
format: 'esm', | ||
sourcemap: true, | ||
preserveModules: true, | ||
}, | ||
], | ||
plugins: [peerDepsExternal(), resolve(), typescript(), filesize()], | ||
}, | ||
{ | ||
input: "src/index.ts", | ||
input: 'src/index.tsx', | ||
output: { | ||
file: "dist/index.umd.js", | ||
format: "umd", | ||
name: "ReactAuthTool", | ||
file: 'dist/index.umd.js', | ||
format: 'umd', | ||
name: 'ReactAuthTool', | ||
sourcemap: true, | ||
globals: { | ||
react: "React", | ||
"react-router-dom": "ReactRouterDOM", | ||
react: 'React', | ||
'react-router-dom': 'ReactRouterDOM', | ||
}, | ||
}, | ||
plugins: [ | ||
peerDepsExternal(), | ||
resolve(), | ||
commonjs(), | ||
typescript({ | ||
tsconfig: "tsconfig.json", | ||
tsconfig: 'tsconfig.json', | ||
}), | ||
terser(), | ||
filesize(), | ||
], | ||
external: ["react", "react-router-dom"], | ||
external: ['react', 'react-router-dom'], | ||
}, | ||
]; | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.