0.1.3 • Published 4 years ago

@ofqwx/use-toggle v0.1.3

Weekly downloads
-
License
UNLICENCED
Repository
github
Last release
4 years ago

useToggle

Simple hook that return a boolean value and a function to toggle it.

Installation

yarn add @ofqwx/useToggle

Example

import useToggle from "@ofqwx/useToggle";
// or from @ofqwx/react-hooks:
// import {useToggle} from "@ofqwx/react-hooks

function YourComponent() {
  const [toggled, toggle] = useToggle();

  return <AnotherComponent display={toggled} onToggle={toggle} />;
}

you can also call it with optional initialiser value (default is false):

const [toggled, toggle] = useToggle(true);

Tests

yarn install
yarn test
0.1.3

4 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.1

5 years ago