1.0.0 • Published 5 years ago

@anmolm/react-use-checkbox v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

react-use-checkbox

npm.io npm.io

⚠️ Warning: Hooks are still in alpha, so only use this for experiments

About

react-use-checkbox is a custom React Hook to use for toggling the state of a Checkbox input. It was inspired by hooks.guide

Install

NOTE: You need to have React 16.7.0-alpha.2 or later installed to use React Hooks (and this package).

    yarn add @anmolm/react-use-checkbox

Usage

useCheckbox: This is a hook that lets you toggle the value of an input of type checkbox. You can pass an initial value of true if you wanted the checkbox to be selected, otherwise it defaults to false.

import React from 'react';
import { useCheckbox } from '@anmolm/react-use-checkbox';

const App = () => {
    const [checked, setChecked] = useCheckbox();
    return (
        <>
            <input
                type="checkbox"
                checked={checked}
                onChange={setChecked}
            /> Checkbox
        </>
    );
}

License

MIT

1.0.0

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago