Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jtsang4/reacooks
🎣 React Hooks for making developing React application easier.
https://github.com/jtsang4/reacooks
react react-hooks
Last synced: 8 days ago
JSON representation
🎣 React Hooks for making developing React application easier.
- Host: GitHub
- URL: https://github.com/jtsang4/reacooks
- Owner: jtsang4
- License: mit
- Created: 2019-08-29T04:04:19.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T00:23:01.000Z (almost 2 years ago)
- Last Synced: 2024-05-02T05:06:13.816Z (7 months ago)
- Topics: react, react-hooks
- Language: TypeScript
- Homepage:
- Size: 826 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Reacooks
React Hooks for making developing React application easier.
## Installation
```bash
npm install reacooks --save
```## Hooks list
### `useToggleValue(truthyValue, falsyValue, truthy)`
Toggle value between `truthyValue` and `falsyValue`. The third parameter `truthy` is optional, default: `true`.
```jsx
import { useToggleValue } from 'reacooks';const App = () => {
const [buttonConfig, toggleButtonConfig] = useToggleValue(
{ text: 'Spread', handler: () => { /* handle spread */ } },
{ text: 'Fold', handler: () => { /* handle fold */ } },
);
// Now `buttonConfig` is { text: 'Spread', handler: () => { /* handle spread */ } }
// After calling toggleButtonConfig() the value would toggle.return {buttonConfig.text};
};
```