https://github.com/nainemom/use-shit
The best use-hook ever made.
https://github.com/nainemom/use-shit
fun hooks-api-react react use-hook vue3
Last synced: 11 months ago
JSON representation
The best use-hook ever made.
- Host: GitHub
- URL: https://github.com/nainemom/use-shit
- Owner: nainemom
- License: mit
- Created: 2024-05-14T17:10:32.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-14T21:27:50.000Z (almost 2 years ago)
- Last Synced: 2025-03-18T20:47:01.778Z (11 months ago)
- Topics: fun, hooks-api-react, react, use-hook, vue3
- Language: TypeScript
- Homepage:
- Size: 43 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# use-shit


> The best use-hook ever made.
## Installation:
```bash
npm i use-shit
```
## Usage
```ts
import { useShit } from 'use-shit';
const REAL_SHIT = [1, 2, 3, 4];
const [shit] = useShit(REAL_SHIT); // shit === REAL_SHIT
```
## Example 1
```tsx
import { useShit } from 'use-shit';
const REAL_SHIT = [1, 2, 3, 4];
function Component() {
- const shit = REAL_SHIT; // ❌ It's ugly
+ const [shit] = useShit(REAL_SHIT); // ✅ Nice and smooth
return (
<>
Thanks god, My code is beautiful!
- {slice}
{ shit.map((slice) => (
)) }
>
);
}
```
## Example 2
```tsx
import { useShit } from 'use-shit';
function Component() {
const [num1, setNum1] = useState(0);
const [num2, setNum2] = useState(0);
- const sum = num1 + num2; // ❌ It doesn't look good
- const sum = useMemo(() => num1 + num2, [num1, num2]); // ❌ Unnessesury use of cache
+ const [sum] = useShit(num1 + num2); // ✅ Nice and feels right
return (
<>
setNum1(e.target.valueAsNumber)} />
setNum2(e.target.valueAsNumber)} />
{sum}
>
);
}
```
## License
[MIT](./LICENSE)
---
