0.2.0 • Published 2 years ago
react-use-native v0.2.0
- 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 anasyncfunction.useDebounce— debounces a function.useError— error dispatcher.useRafLoop— calls given function inside the RAF loop.useThrottleanduseThrottleFn— throttles a function.
- Lifecycles
useEffectOnce— a modifieduseEffecthook that only runs once.useLifecycles— callsmountandunmountcallbacks.useMountedStateanduseUnmountPromise— track if component is mounted.usePromise— resolves promise only while component is mounted.useLogger— logs in console as component goes through life-cycles.useMount— callsmountcallbacks.useUnmount— callsunmountcallbacks.useUpdateEffect— run aneffectonly on updates.useIsomorphicLayoutEffect—useLayoutEffectthat that works on server.useDeepCompareEffect,useShallowCompareEffect, anduseCustomCompareEffect
- State
createMemo— factory of memoized hooks.createReducer— factory of reducer hooks with custom middleware.createReducerContextandcreateStateContext— factory of hooks for a sharing state between components.useDefault— returns the default value when state isnullorundefined.useGetSet— returns state getterget()instead of raw state.useGetSetState— as ifuseGetSetanduseSetStatehad a baby.useLatest— returns the latest state or propsusePrevious— returns the previous state or props.usePreviousDistinct— likeusePreviousbut with a predicate to determine ifpreviousshould update.useObservable— tracks latest value of anObservable.useRafState— createssetStatemethod which only updates afterrequestAnimationFrame.useSetState— createssetStatemethod which works likethis.setState.useStateList— circularly iterates over an array.useToggleanduseBoolean— tracks state of a boolean.useCounteranduseNumber— 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 regularuseStatebut 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
useEnsuredForwardedRefandensuredForwardRef— use a React.forwardedRef safely.