Skip to content

anmolm96/react-use-checkbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-use-checkbox

⚠️ 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

About

Custom Hook for toggling Checkboxes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published