How streamich/react-use works
react-use is a library of React hooks and hook factories. A consumer imports hooks from the package entry point and uses them to observe browser/device state, manage UI interactions, coordinate asynchronous work and timing, or maintain application state. Those hooks return state, callbacks, or controls for the consuming component. The README documents these capability areas; several implementations were not sampled, so their internal wiring is not inferred here.
Main entry points: index.ts Public exports · useAsync.ts Async state · useAsyncFn.ts Async callbacks · useKey.ts Keyboard events
Components 25
Sensors and navigation
- Device sensors
src/useBattery.ts - Geolocation
src/useGeolocation.ts - Keyboard events
src/useKey.ts - Location and query
src/useSearchParam.ts - Other sensor hooks
src - Event callback
src/useEvent.ts
UI and media
- Drop interactions
src/useDrop.ts - Fullscreen controls
src/useFullscreen.ts - Audio and video
src/factory/createHTMLMediaHook.ts - Other UI hooks
src - Layout effect
src/useIsomorphicLayoutEffect.ts - Drop area
src/useDropArea.ts
State and storage
- Counter state
src/useCounter.ts - Shared state helpers
src/misc/hookState.ts - Object state
src/useSetState.ts - Browser storage
src/useLocalStorage.ts - Other state hooks
src
Async and timing
- Async state
src/useAsync.ts - Async callbacks
src/useAsyncFn.ts - Async retry
src/useAsyncRetry.ts - Animation and timers
src - Hook lifecycle
src/useEffectOnce.ts - Mounted-state check
src/useMountedState.ts
Other components
- React consumer
- Public exports
src/index.ts
Connections 24
- React consumer → Public exports: imports hooks
src/index.ts - Public exports → Device sensors: exports
src/index.ts - Public exports → Geolocation: exports
src/index.ts - Public exports → Keyboard events: exports
src/index.ts - Public exports → Location and query: exports
src/index.ts - Public exports → Drop interactions: exports
src/index.ts - Public exports → Fullscreen controls: exports
src/index.ts - Public exports → Counter state: exports
src/index.ts - Public exports → Browser storage: exports
src/index.ts - Public exports → Async state: exports
src/index.ts - Public exports → Async callbacks: exports
src/index.ts - Public exports → Async retry: exports
src/index.ts - Public exports → Other sensor hooks: exports sensor hooks
src/index.ts - Public exports → Other UI hooks: exports UI hooks
src/index.ts - Public exports → Other state hooks: exports state hooks
src/index.ts - Public exports → Animation and timers: exports timing hooks
src/index.ts - Counter state → Shared state helpers: resolves state
src/useCounter.ts - Drop area → Mounted-state check: checks mounted
src/useDropArea.ts - Keyboard events → Event callback: uses callback
src/useKey.ts - Fullscreen controls → Layout effect: uses layout effect
src/useFullscreen.ts - Audio and video → Object state: updates state
src/factory/createHTMLMediaHook.ts - Async state → Async callbacks: delegates to
src/useAsync.ts - Async retry → Async state: wraps
src/useAsyncRetry.ts - Async callbacks → Mounted-state check: checks mounted
src/useAsyncFn.ts