Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeetiss/ucs
another controlled state hook
https://github.com/jeetiss/ucs
controlled hooks react state uncontrolled
Last synced: 19 days ago
JSON representation
another controlled state hook
- Host: GitHub
- URL: https://github.com/jeetiss/ucs
- Owner: jeetiss
- Created: 2019-02-16T17:35:09.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-18T10:03:18.000Z (almost 6 years ago)
- Last Synced: 2024-04-24T12:03:46.867Z (9 months ago)
- Topics: controlled, hooks, react, state, uncontrolled
- Language: TypeScript
- Homepage: https://jeetiss.github.io/ucs/
- Size: 938 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ucs
> another controlled state hook
[![NPM](https://img.shields.io/npm/v/ucs.svg)](https://www.npmjs.com/package/ucs) [![bundlephobia](https://img.shields.io/bundlephobia/minzip/ucs.svg?style=flat)](https://bundlephobia.com/result?p=ucs) [![travis](https://img.shields.io/travis/com/jeetiss/ucs.svg?style=flat)](https://travis-ci.com/jeetiss/ucs/)
## Install
```bash
npm install ucs
```## Usage
```jsx
import React from "react";
import useControlledState from "ucs";const Toggler = ({ value, onChange, defaultValue }) => {
const [state, setState] = useControlledState(() => value || defaultValue);return (
setState(!state)}>{state ? "on" : "off"}
);
};
```## demo
see demo and example of usage on [gh-pages](https://jeetiss.github.io/ucs/)
## License
MIT © [jeetiss](https://github.com/jeetiss)