/usehooks-ts

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

Primary LanguageTypeScriptMIT LicenseMIT

usehooks-ts banner


usehooks-ts

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

Netlify Status Open Source? Yes! Maintained License lerna npm bundle size npm All Contributors


npm i usehooks-ts

Created by Julien Caron and maintained with ❀️ by an amazing team of developers.

πŸ€” About

Initially, usehooks-ts was a Gatsby powered blog hosted with Github & netlify that publishes easy to understand React Hook code snippets.

But now, it's a monorepo containing:

  • A static website used as hooks documentation (Link).
  • An NPM package containing the hooks library (Link).

If you'd like to submit new post ideas, improve existing posts, or change anything about the website feel free to submit an issue or pull-request.

πŸ“– Summary

Usage

install

npm i usehooks-ts

Then go to the documentation.

🀝 How to Contribute

Thanks for wanting to contribute! It's more than welcome πŸ€—

Content changes

Most content changes (like fixing a typo) can be made without cloning the repository. Simply locate the file you wish to change in the GitHub UI, and click the little edit icon to make your change directly on the GitHub website.

If you need to make any other substantial changes, then follow the project setup steps below.

Fork to submit a Pull Request (PR)

This project use npm Lerna and npm@8 to manage the different packages. Before starting, make sure you have the good system dependencies:

  • node@^16
  • npm@^8

Note: To easily switch node version, consider Node Version Manager (nvm).

Then you can fork, download and install the repository:

# 1) Fork the repository (button in the Github top-right corner)

# 2) Clone the repository
git clone https://github.com/{your_username}/usehooks-ts.git
cd usehooks-ts

# 3) Install dependencies and setup
npm run bootstrap

Create a new hook

# This command will regenerate all the hook boilerplate
npm run plop

# Then develop the hook (aka test:watch)
npm run dev:lib

# Once the hooks is ready
# Launch the documentation website
npm run dev:site

# Before commit: exec types-checking, linters and tests
npm run test

How is structured a hook ?

The hook itself and its unit tests are in the /lib/src/ folder. It's the strict npm run test

πŸ“‚ lib/src
β”œβ”€β”€ πŸ“‚ useHookName
β”‚  β”œβ”€β”€ πŸ“„ index.ts # used for exports
β”‚  β”œβ”€β”€ πŸ§ͺ useHookName.test.ts # unit tests
β”‚  └── πŸ“„ useHookName.ts # the hook
...

The rest is in the documentation website:

πŸ“‚ site/src/hooks-doc
β”œβ”€β”€ πŸ“‚ useHookName
β”‚  β”œβ”€β”€ πŸ“„ index.ts # used for exports
β”‚  β”œβ”€β”€ πŸ“„ useHookName.demo.tsx # working demo
β”‚  └── πŸ“ useHookName.mdx # the documentation content
...

Note: The demo is used different way:

  • It's displayed on the website to illustrate how to use the hook.
  • It's displayed as an interactive sandbox in the hook page during the dev.
  • It's deployed as a CodeSandbox on build to let final users play with.

✨ Contributors

Big thanks goes to these wonderful people ❀️


Julien

πŸ–‹ πŸ’» 🎨 πŸ€”

a777med

πŸ’»

Nguyen Tien Dat

πŸ’»

Elias Cohenca

πŸ–‹

JoΓ£o Deroldo

πŸ› πŸ’»

Nishit

πŸ’»

Jon Koops

πŸ’»

LoneRifle

πŸ’»

Viktor

πŸ€” πŸ›

Bruno Clermont

πŸ’¬

yoannesbourg

πŸ€”

Strange2x

πŸ€”

Jason Pickens

πŸ›

Sel-Vin Kuik

πŸ›

isaac

πŸ›

Bruno RZN

πŸ’» πŸ‘€

Nathan Manceaux-Panot

πŸ’» πŸ‘€

Dien Vu

πŸ€”

Oleg Kusov

πŸ€”

Matthew Guy

πŸ€”

andrewbihl

πŸ›

lancepollard

πŸ›

Mukul Bansal

πŸ›

Jean-Luc Mongrain sur la Brosse

πŸ’» πŸ€”

Nic

πŸ–‹

Dan Wood

πŸ’»

jo wendenbuerger

πŸ›

Andrew Nosenko

πŸ›

CharlieJhonSmith

πŸ’»

Sullivan SENECHAL

πŸ€” πŸ›

Jason Long

πŸ›

kxm766

πŸ›

Quentin

πŸ’» πŸ€” πŸ–‹

Daniel Lazar

πŸ’» πŸ›

Mark Terrel

πŸ› πŸ’»

Andreas Herd

πŸ›

Sonjoy Datta

πŸ’»

Ilya Belsky

πŸ›

James Barrett

πŸ’»

AbbalYouness

πŸ’»

didriklind

πŸ’»

hexp1989

πŸ’»

Alvaro Serrano

πŸ–‹

Egehan DΓΌlger

πŸ’»

PabloLION

πŸ› πŸ’»

David Sanchez

πŸ›

Ajay Raja

πŸ›

Andy Merskin

πŸ€”

Avirup Ghosh

πŸ’» πŸ›

Sanne WintrΓ©n

πŸ›

Alessandro

πŸ›

Andrey Tatarenko

πŸ›

Anton Rusak

πŸ›

Mahmood Bagheri

πŸ’»

Anver Sadutt

πŸ–‹

Bogdan Ailincai

πŸ› πŸ’»

Simeon Griggs

πŸ›

Kepro

πŸ›

Jake Lippert

πŸ›

Tu Nguyen Anh

πŸ› πŸ’»

Luke Shiels

πŸ›

Sergei Kolyago

πŸ€”

Adham Akmal Azmi

πŸ›

Alek Kowalczyk

πŸ›

This project follows the all-contributors specification (emoji key). Contributions of any kind welcome!

πŸš— Roadmap

  • Add new hooks (web3 hooks are welcome!)
  • Develop automated tests for all hooks

πŸ“ License

This project is MIT licensed.