reacooks
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Reacooks

React Hooks for making developing React application easier.

Installation

npm install reacooks --save

Hooks list

useToggleValue(truthyValue, falsyValue, truthy)

Toggle value between truthyValue and falsyValue. The third parameter truthy is optional, default: true.

import { useToggleValue } from 'reacooks';

const App = () => {
  const [button, toggleButton] = useToggleValue(
    { showAll: false, text: 'Spread', handler: () => { /* handle spread */ } },
    { showAll: true, text: 'Fold', handler: () => { /* handle fold */ } },
  );
  // Now `button` is { showAll: false, text: 'Spread', handler: () => { /* handle spread */ } }
  // After calling toggleButton() the value would toggle.

  return <button onClick={button.handler}>{button.text}</button>;
};

Readme

Keywords

none

Package Sidebar

Install

npm i reacooks

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

6.56 kB

Total Files

7

Last publish

Collaborators

  • wtzeng