A React Hooks utility library containing popular customized hooks
What's your favorite dish?
npm i react-recipes --save
yarn add react-recipes
Name | Returns | Arguments |
---|---|---|
๐ก useAdjustColor |
color | (percentage, color1, color2: null, linearBlend: false) |
๐ฅ useArray |
{ value, setValue, removeById, removeIndex, clear } | (initialValue) |
๐ useAsync |
{ error, execute, pending, value } | (asyncFunction, immediate: true) |
๐ช useCookie |
[cookieValue, updateCookie, deleteCookie] | (cookieName, initialValue) |
๐ฅ useCopyClipboard |
[isCopied, setIsCopied] | (duration: 2000) |
๐ฉ useDarkMode |
[enabled, setEnabledState] | - |
๐ useDebounce |
debouncedValue | (value, delay) |
๐ฅก useDimensions |
[ref, dimensions, node] | (liveMeasure: true, delay: 250, initialDimensions: {}, effectDependencies: []) |
๐ณ useEventListener |
- | (eventName, handle, element: window) |
๐ฎ useFullScreen |
{ fullScreen, open, close, toggle } | (element: document.documentElement) |
๐ฏ useGeolocation |
{ latitude, longitude, timestamp, accuracy, error } | (watch: false, settings: {enableHighAccuracy: false, timeout: Infinity, maximumAge: 0}) |
๐ญ useHover |
[callbackRef, value] | - |
๐ฆ useInterval |
- | (callback, delay, runOnLoad: false, effectDependencies: []) |
๐ useIsClient |
isClient | - |
๐ฅง useKeyPress |
keyPressed | (targetKey) |
๐ฑ useLocalStorage |
[storedValue, setValue] | (key, initialValue) |
๐ useLocation |
{ push, replace, pathname, search } | - |
๐ useLockBodyScroll |
- | - |
๐ useMedia |
value | (queries, values, defaultValue) |
๐ฅญ useMultiKeyPress |
keysPressed | (targetKey) |
๐ useNotification |
fireNotify | (title, options) |
๐ฅ useOnClickOutside |
- | (ref, callback) |
๐ฅ useOnlineStatus |
onlineStatus | - |
๐ฟ usePrevious |
previous | (value) |
๐จ usePrint |
{ ref, handlePrint } | (style = {}) |
โ useQueryParams |
{ getParams, setParams } | - |
๐ฃ useScript |
[loaded, error] | (src) |
๐ useSpeechRecognition |
{ supported, listen, listening, stop } | ({ onEnd, onResult, onError }) |
๐ useSpeechSynthesis |
{ supported, speak, speaking, cancel, voices, pause, resume } | ({ onEnd, onResult, onError, onBoundary, onPause, onResume }) |
๐ useThrottle |
throttledValue | (value, ms: 250) |
๐ท useWhyDidYouUpdate |
- | (name, props) |
๐ฅ useWindowScroll |
{ x, y } | - |
๐ฅฎ useWindowSize |
{ height, width } | (initialWidth, initialHeight) |
๐ฅ useWorker |
worker instance | (scriptPath, workerOptions, attributes) |