A React-style hooks library designed specifically for ReactLynx.
Translations: π¨π³ ζ±θ―
npm i @lynx-js/react-use
- π― ReactLynx Compatible β seamlessly integrates with ReactLynx applications
- βοΈ React-Style API β familiar hooks interface for React developers
- π§ Cross-Platform β built with Lynx's unique cross-platform capabilities in mind
- MainThreadScripts
useMainThreadImperativeHandleβ main-thread version of React's useImperativeHandle.useTapLockβ a hook for locking tap events.useVelocityβ a hook that tracks touch velocity and direction with smoothing support.
- Lifecycles
useEffectOnceβ a modifieduseEffecthook that only runs once.useEventListenerβ a hook that helps you add a global event listener as early as possible.useLifecyclesβ callsmountandunmountcallbacks.useMountedStateanduseUnmountPromiseβ track if component is mounted.useUnmountβ callsunmountcallbacks.useUpdateEffectβ run aneffectonly on updates.
- SideEffects
useDebounceβ debounces a function.useErrorβ error dispatcher.useThrottleanduseThrottleFnβ throttles a function.
- State
createMemoβ factory of memoized hooks.useToggleanduseBooleanβ tracks state of a boolean.useCounteranduseNumberβ tracks state of a number.useDefaultβ returns the default value when state isnullorundefined.useLatestβ returns the latest state or propsuseMapβ tracks state of an object.usePreviousβ returns the previous state or props.useQueueβ implements simple queue.useSetβ tracks state of a Set.useSetStateβ createssetStatemethod which works likethis.setState.
Many hooks in this library are built upon the excellent foundation provided by react-use. We extend our gratitude to the maintainers and contributors for their outstanding work in the React hooks ecosystem.
We also draw inspiration from other amazing projects:
Made with β€οΈ for the ReactLynx community