Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jeetiss/ucs

another controlled state hook
https://github.com/jeetiss/ucs

controlled hooks react state uncontrolled

Last synced: 2 days ago
JSON representation

another controlled state hook

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)