- Sensors
useBatteryβ tracks device battery state.useGeolocationβ tracks geo location state of user's device.useHoverβ tracks mouse hover state of some element.useIdleβ tracks whether user is being inactive.useLocationβ tracks page navigation bar location state.useMediaβ tracks state of a CSS media query.useMediaDevicesβ tracks state of connected hardware devices.useMotionβ tracks state of device's motion sensor.useNetworkβ tracks state of user's internet connection.useOrientationβ tracks state of device's screen orientation.useSizeβ tracks some HTML element's dimensions.useWindowSizeβ tracksWindowdimensions.
- UI
- Animations
useRafβ re-renders component on eachreaquestAnimationFrame.useSpringβ interpolates number over time according to spring dynamics.useTimeoutβ returns true after a timeout.useTweenβ re-renders component, while tweening a number from 0 to 1.
- Side-effects
useAsyncβ resolves anasyncfunction.useCssβ dynamically adjusts CSS.useFaviconβ sets favicon of the page.useTitleβ sets title of the page.
- Lifecycles
useLifecyclesβ callsmountandunmountcallbacks.useLoggerβ logs in console as component goes though life-cycles.useMountβ callsmountcallbacks.useUnmountβ callsunmountcallbacks.
- State
useObservableβ tracks latest value of anObservable.useSetStateβ createssetStatemethod which works likethis.setState.useToggleβ tracks state of a boolean.useCounterβ tracks state of a number.useListβ tracks state of an array.useMapβ tracks state of an object.
- You need to have React
16.7.0-alpha.0or later installed to use Hooks API. - You can import each hook individually
import useToggle from 'react-use/lib/useToggle'.
Unlicense β public domain.