Skip to content

jeetiss/ucs

Repository files navigation

ucs

another controlled state hook

NPM bundlephobia travis

Install

npm install ucs

Usage

import React from "react";
import useControlledState from "ucs";

const Toggler = ({ value, onChange, defaultValue }) => {
  const [state, setState] = useControlledState(() => value || defaultValue);

  return (
    <button onClick={() => setState(!state)}>{state ? "on" : "off"}</button>
  );
};

demo

see demo and example of usage on gh-pages

License

MIT © jeetiss