https://github.com/bansal/react-toggle-value
React custom hook to toggle value between two given values
https://github.com/bansal/react-toggle-value
react react-hooks toggle
Last synced: 11 months ago
JSON representation
React custom hook to toggle value between two given values
- Host: GitHub
- URL: https://github.com/bansal/react-toggle-value
- Owner: bansal
- License: mit
- Created: 2023-10-12T12:32:38.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-10-12T12:38:43.000Z (over 2 years ago)
- Last Synced: 2025-02-02T14:35:32.562Z (11 months ago)
- Topics: react, react-hooks, toggle
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/react-toggle-value
- Size: 2.93 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# useToggleValue
`useToggleValue` is a custom React hook to toggle value between two given values
## Installation
```sh
# Using npm.
npm install react-toggle-value
```
## Usage
```jsx
import useToggleValue from "react-toggle-value";
const [
color,
toggle,
turnRed,
turnGreen
] = useToggleValue('red', ['red', 'green']);
const [ loading, toggle ] = useToggleValue(false);
```
## Contributing
Please feel free to submit any issues or pull requests.
## License
MIT