- Sensors
useBattery
β tracks device battery state.useGeolocation
β tracks geo location state of user's device.useHover
anduseHoverDirty
β tracks mouse hover state of some element.useIdle
β tracks whether user is being inactive.useKeyPress
β tracks whether a keyboard keyβor set of keysβwas pressed.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
β tracksWindow
dimensions.
- UI
useAudio
β plays audio and exposes its controls.useOutsideClick
β triggers callback when user clicks outside target area.useSpeech
β synthesizes speech from a text string.useVideo
β plays video, tracks its state, and exposes playback controls.useWait
β complex waiting management for UIs.
- Animations
useRaf
β re-renders component on eachrequestAnimationFrame
.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.useUpdate
β returns a callback, which re-renders component when called.
- Side-effects
useAsync
β resolves anasync
function.useCss
β dynamically adjusts CSS.useFavicon
β sets favicon of the page.useLocalStorage
β manages a value inlocalStorage
.useSessionStorage
β manages a value insessionStorage
.useTitle
β sets title of the page.useDebounce
β debounces a function.
- Lifecycles
useLifecycles
β callsmount
andunmount
callbacks.useRefMounted
β tracks if component is mounted.useLogger
β logs in console as component goes through life-cycles.useMount
β callsmount
callbacks.useUnmount
β callsunmount
callbacks.
- State
createMemo
β factory of memoized hooks.useCallbag
β tracks latest value of a callbag.useGetSet
β returns state getterget()
instead of raw state.useGetSetState
β as ifuseGetSet
anduseSetState
had a baby.useObservable
β tracks latest value of anObservable
.useSetState
β createssetState
method which works likethis.setState
.useToggle
anduseBoolean
β tracks state of a boolean.useCounter
anduseNumber
β 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.0
or later installed to use Hooks API.
You can import each hook individually import useToggle from 'react-use/lib/useToggle'
.
Unlicense β public domain.