React hook library, ready to use, written in Typescript.
npm i usehooks-ts
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:
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.
useBoolean()useClickAnyWhere()useCopyToClipboard()useCountdown()useCounter()useDarkMode()useDebounce()useEffectOnce()useElementSize()useEventListener()useFetch()useHover()useImageOnLoad()useIntersectionObserver()useInterval()useIsClient()useIsFirstRender()useIsMounted()useLocalStorage()useLockedBody()useMap()useMediaQuery()useOnClickOutside()useReadLocalStorage()useScreen()useScript()useSsr()useStep()useTernaryDarkMode()useTimeout()useUpdateEffect()useWindowSize()npm i usehooks-ts
Then go to the documentation.
Thanks for wanting to contribute! Itβs more than welcome π€
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.
This project use npm Lerna and npm@8 to manage the different packages.
Before starting, make sure you have the good system dependencies:
node@^16npm@^8Note: 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
# 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
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:
Big thanks goes to these wonderful people β€οΈ
This project follows the all-contributors specification (emoji key). Contributions of any kind welcome!
This project is MIT licensed.