https://github.com/ericc-ch/molohooks
React hooks for common use cases
https://github.com/ericc-ch/molohooks
Last synced: about 1 year ago
JSON representation
React hooks for common use cases
- Host: GitHub
- URL: https://github.com/ericc-ch/molohooks
- Owner: ericc-ch
- Created: 2020-11-13T13:24:49.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-13T14:21:49.000Z (over 5 years ago)
- Last Synced: 2025-02-13T09:32:07.570Z (over 1 year ago)
- Language: TypeScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Molohooks
only 2 hooks, mainly for my personal use
## Hooks
### useToggler
For boolean state
Params
1. `defaultValue: boolean` : Default value for the state
Returns
1. `value: boolean` : The value of the state
1. `setTrue: () => void` : Set the state to `true`
1. `setFalse: () => void` : Set the state to `false`
1. `toggler: () => void` : Toggle the state
### useInputHandler
For controlled input handler
Params
1. `defaultValue: string` : Default value for the state
Returns
1. `value: boolean` : The value of the state
1. `handleChange: (e: ChangeEvent) => void` : Handler for onChange event on input element
1. `clearValue: () => void` : Set the value to an empty string (`''`)