JSPM

rooks

9.0.0-next.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 112516
  • Score
    100M100P100Q158455F
  • License MIT

Essential React custom hooks โš“ to super charge your components!

Package Exports

  • rooks
  • rooks/experimental
  • rooks/package.json

Readme




CI and Semantic Release GitHub GitHub release (latest by date) GitHub contributors npm npm bundle size Codecov branch node-lts Website Module




Essential React custom hooks โš“ to super charge your components!



List of all hooks

๐ŸŽฌ Animation & Timing - 5 hooks

  • useIntervalWhen - Sets an interval immediately when a condition is true
  • useLockBodyScroll - This hook locks the scroll of the body element when isLocked is set to true.
  • useRaf - A continuously running requestAnimationFrame hook for React
  • useResizeObserverRef - Resize Observer hook for React.
  • useTimeoutWhen - Takes a callback and fires it when a condition is true

๐ŸŒ Browser APIs - 9 hooks

๐Ÿ› ๏ธ Development & Debugging - 1 hook

๐Ÿš€ Events - 15 hooks

๐Ÿ“ Form & File Handling - 1 hook

โŒจ๏ธ Keyboard & Input - 5 hooks

  • useInput - Input hook for React.
  • useKey - keypress, keyup and keydown event handlers as hooks for react.
  • useKeyBindings - useKeyBindings can bind multiple keys to multiple callbacks and fire the callbacks on key press.
  • useKeyRef - Very similar useKey but it returns a ref
  • useKeys - A hook which allows to setup callbacks when a combination of keys are pressed at the same time.

๐Ÿ”ฅ Lifecycle & Effects - 9 hooks

๐Ÿ–ฑ๏ธ Mouse & Touch - 3 hooks

โšก Performance & Optimization - 4 hooks

โ‡๏ธ State - 18 hooks

  • useArrayState - Array state manager hook for React
  • useCountdown - Count down to a target timestamp and call callbacks every second (or provided peried)
  • useCounter - Counter hook for React.
  • useGetIsMounted - Checks if a component is mounted or not at the time. Useful for async effects
  • useLocalstorageState - UseState but auto updates values to localStorage
  • useMapState - A react hook to manage state in a key value pair map.
  • useMultiSelectableList - A custom hook to easily select multiple values from a list
  • useNativeMapState - Manage Map() object state in React
  • usePreviousDifferent - usePreviousDifferent returns the last different value of a variable
  • usePreviousImmediate - usePreviousImmediate returns the previous value of a variable even if it was the same or different
  • usePromise - Promise management hook for react
  • useQueueState - A React hook that manages state in the form of a queue
  • useSafeSetState - set state but ignores if component has already unmounted
  • useSelect - Select values from a list easily. List selection hook for react.
  • useSelectableList - Easily select a single value from a list of values. very useful for radio buttons, select inputs etc.
  • useSessionstorageState - useState but syncs with sessionstorage
  • useSetState - Manage the state of a Set in React.
  • useStackState - A React hook that manages state in the form of a stack

๐Ÿ”„ State History & Time Travel - 4 hooks

  • useTimeTravelState - A hook that manages state which can undo and redo. A more powerful version of useUndoState hook.
  • useToggle - Toggle (between booleans or custom data)hook for React.
  • useUndoRedoState - Setstate but can also undo and redo
  • useUndoState - Drop in replacement for useState hook but with undo functionality.

โš›๏ธ UI - 12 hooks

๐Ÿ”ง Utilities & Refs - 7 hooks

  • useEventListenerRef - A react hook to add an event listener to a ref
  • useForkRef - A hook that can combine two refs(mutable or callbackRefs) into a single callbackRef
  • useFreshCallback - Avoid stale closures and keep your callback fresh
  • useFreshRef - Avoid stale state in callbacks with this hook. Auto updates values using a ref.
  • useFreshTick - Like use-fresh-ref but specifically for functions
  • useMergeRefs - Merges any number of refs into a single ref
  • useRefElement - Helps bridge gap between callback ref and state

๐Ÿ“ฑ Window & Viewport - 2 hooks

๐Ÿงช Experimental Hooks - 2 hooks

โš ๏ธ Experimental hooks may be removed or significantly changed in any release without notice. Use with caution in production.



Features

โœ… Collection of 97 hooks as standalone modules.

โœ… Standalone package with all the hooks at one place

โœ… CommonJS, UMD and ESM Support

Installation

npm i -s rooks

Import any hook from "rooks" and start using them!

import { useDidMount } from "rooks";

Usage

function App() {
  useDidMount(() => {
    alert("mounted");
  });
  return (
    <div className="App">
      <h1>Hello CodeSandbox</h1>
      <h2>Start editing to see some magic happen!</h2>
    </div>
  );
}

Standalone Package

Package containing all the hooks is over here. - Docs and Npm Install


License

MIT

Contributors โœจ

All Contributors

Thanks goes to these wonderful people (emoji key):


Bhargav Ponnapalli

๐Ÿ’ป ๐Ÿšง

anil kumar chaudhary

๐Ÿ’ป

Qiwei Yang

๐Ÿ’ป ๐Ÿšง

maciek_grzybek

๐Ÿ’ป

Harsh Zalavadiya

๐Ÿ’ป

B V K MAHIJENDRA

๐Ÿ’ป

Braxton Christensen

๐Ÿ’ป

Hansel

๐Ÿ’ป

Harshil Parmar

๐Ÿ’ป

Lionel

๐Ÿ’ป

Max Stoiber

๐Ÿ’ป

Michael Moore

๐Ÿ’ป

Rajas Paranjpe

๐Ÿ’ป

Mahendra Choudhary

๐Ÿ’ป

Nghia Pham

๐Ÿ’ป

Akshay Kadam (A2K)

๐Ÿ’ป

Alex Golubtsov

๐Ÿ’ป

Arman

๐Ÿ’ป

Branden Visser

๐Ÿ’ป

Brian Steere

๐Ÿ’ป

Cal Courtney

๐Ÿ’ป

Chris Milson

๐Ÿ’ป

Cong Zhang

๐Ÿ’ป

Daniel Holmes

๐Ÿ’ป

Fernando Beck

๐Ÿ’ป

Josh Davenport

๐Ÿ’ป

MARCEL

๐Ÿ’ป

Neilor Caldeira

๐Ÿ’ป

Tobias Lins

๐Ÿ’ป

Tsvetan

๐Ÿ’ป

Wei Zhu

๐Ÿ’ป

Yakko Majuri

๐Ÿ’ป

Frank Hellwig

๐Ÿ’ป

Austin Peterson

๐Ÿ’ป

thodubois

๐Ÿ’ป

wes christiansen

๐Ÿ’ป

CJ Patoilo

๐Ÿ’ป

mar1u50

๐Ÿ’ป

Ayushman Gupta

๐Ÿ’ป

Rafael Ferreira

๐Ÿ’ป

Kristinn Thor Johannsson

๐Ÿ’ป

Michael Moore

๐Ÿ’ป

Trevor Blades

๐Ÿ’ป

official_dulin

๐Ÿ’ป

Billy Mosis Priambodo

๐Ÿ’ป

Stafford Williams

๐Ÿ’ป

Chanhee Kim

๐Ÿ’ป

Hooriza

๐Ÿ’ป

Nils Wittler

๐Ÿ’ป

Sebastian Szczepaล„ski

๐Ÿ’ป

Mahendra Choudhary

๐Ÿ’ป

Som Shekhar Mukherjee

๐Ÿ’ป

Qiushi Pan

๐Ÿ’ป

Jishnu Viswanath

๐Ÿ’ป

brahambence

๐Ÿ’ป

dependabot[bot]

๐Ÿ’ป

renovate[bot]

๐Ÿ’ป

dependabot-preview[bot]

๐Ÿ’ป

github-actions[bot]

๐Ÿ’ป

allcontributors[bot]

๐Ÿ’ป

zhangenming

๐Ÿ’ป

Antoni Kiszka

๐Ÿ’ป

Greg Poole

๐Ÿ’ป