react-use-native
v0.2.0
Published
Collection of React Native Hooks (fork of react-use)
Downloads
2,065
Readme
- Animations
useRaf
— re-renders component on eachrequestAnimationFrame
.useInterval
— re-renders component on a set interval usingsetInterval
.useTimeout
— re-renders component after a timeout.useTimeoutFn
— calls given function after a timeout.useUpdate
— returns a callback, which re-renders component when called.
- Side-effects
useAsync
,useAsyncFn
, anduseAsyncRetry
— resolves anasync
function.useDebounce
— debounces a function.useError
— error dispatcher.useRafLoop
— calls given function inside the RAF loop.useThrottle
anduseThrottleFn
— throttles a function.
- Lifecycles
useEffectOnce
— a modifieduseEffect
hook that only runs once.useLifecycles
— callsmount
andunmount
callbacks.useMountedState
anduseUnmountPromise
— track if component is mounted.usePromise
— resolves promise only while component is mounted.useLogger
— logs in console as component goes through life-cycles.useMount
— callsmount
callbacks.useUnmount
— callsunmount
callbacks.useUpdateEffect
— run aneffect
only on updates.useIsomorphicLayoutEffect
—useLayoutEffect
that that works on server.useDeepCompareEffect
,useShallowCompareEffect
, anduseCustomCompareEffect
- State
createMemo
— factory of memoized hooks.createReducer
— factory of reducer hooks with custom middleware.createReducerContext
andcreateStateContext
— factory of hooks for a sharing state between components.useDefault
— returns the default value when state isnull
orundefined
.useGetSet
— returns state getterget()
instead of raw state.useGetSetState
— as ifuseGetSet
anduseSetState
had a baby.useLatest
— returns the latest state or propsusePrevious
— returns the previous state or props.usePreviousDistinct
— likeusePrevious
but with a predicate to determine ifprevious
should update.useObservable
— tracks latest value of anObservable
.useRafState
— createssetState
method which only updates afterrequestAnimationFrame
.useSetState
— createssetState
method which works likethis.setState
.useStateList
— circularly iterates over an array.useToggle
anduseBoolean
— tracks state of a boolean.useCounter
anduseNumber
— tracks state of a number.useList
~anduseUpsert
~ — tracks state of an array.useMap
— tracks state of an object.useSet
— tracks state of a Set.useQueue
— implements simple queue.useStateValidator
— tracks state of an object.useStateWithHistory
— stores previous state values and provides handles to travel through them.useMultiStateValidator
— alike theuseStateValidator
, but tracks multiple states at a time.useMediatedState
— like the regularuseState
but with mediation by custom function.useFirstMountState
— check if current render is first.useRendersCount
— count component renders.createGlobalState
— cross component shared state.useMethods
— neat alternative touseReducer
.
- Miscellaneous
useEnsuredForwardedRef
andensuredForwardRef
— use a React.forwardedRef safely.