Skip to content

mmartinsoliv/easy-hooks-ts

Repository files navigation

easy-hooks-ts

React hook library, ready to use, written in Typescript.

License: MIT NPM version


Status

This project is “semi-maintained” 😅

I don't have the bandwidth right now to look into edge-case issues or help troubleshoot, but I plan on keeping it up-to-date with major React releases, and fixing issues that are both serious and common.

Feel free to create a pull request or issues for features, bug fixes or improvements.


Installation

Package can be added using:

Yarn

yarn add easy-hooks-ts

NPM

npm install easy-hooks-ts

PNPM

pnpm install easy-hooks-ts

Demo

Open in StackBlitz


Examples

Use easy-hooks-ts

import { useToggle } from 'easy-hooks-ts'
 
export const Component = () => {
  const [value, toggle, setValue] = useToggle()
 
  const customToggle = () => setValue((x: boolean) => !x)
 
  return (
    <>
      <p>
        Value is <code>{value.toString()}</code>
      </p>
      <button onClick={() => setValue(true)}>set true</button>
      <button onClick={() => setValue(false)}>set false</button>
      <button onClick={toggle}>toggle</button>
      <button onClick={customToggle}>custom toggle</button>
    </>
  )
}

API Documentation

website-documentation

Contributing

Read our contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to easy-hooks-ts.