0.2.0 • Published 2 years ago
react-use-native v0.2.0
- Animations- useRaf— re-renders component on each- requestAnimationFrame.
- useInterval— re-renders component on a set interval using- setInterval.
- 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, and- useAsyncRetry— resolves an- asyncfunction.
- useDebounce— debounces a function.
- useError— error dispatcher.
- useRafLoop— calls given function inside the RAF loop.
- useThrottleand- useThrottleFn— throttles a function.
 
- Lifecycles- useEffectOnce— a modified- useEffecthook that only runs once.
- useLifecycles— calls- mountand- unmountcallbacks.
- useMountedStateand- useUnmountPromise— track if component is mounted.
- usePromise— resolves promise only while component is mounted.
- useLogger— logs in console as component goes through life-cycles.
- useMount— calls- mountcallbacks.
- useUnmount— calls- unmountcallbacks.
- useUpdateEffect— run an- effectonly on updates.
- useIsomorphicLayoutEffect—- useLayoutEffectthat that works on server.
- useDeepCompareEffect,- useShallowCompareEffect, and- useCustomCompareEffect
 
- State- createMemo— factory of memoized hooks.
- createReducer— factory of reducer hooks with custom middleware.
- createReducerContextand- createStateContext— factory of hooks for a sharing state between components.
- useDefault— returns the default value when state is- nullor- undefined.
- useGetSet— returns state getter- get()instead of raw state.
- useGetSetState— as if- useGetSetand- useSetStatehad a baby.
- useLatest— returns the latest state or props
- usePrevious— returns the previous state or props.
- usePreviousDistinct— like- usePreviousbut with a predicate to determine if- previousshould update.
- useObservable— tracks latest value of an- Observable.
- useRafState— creates- setStatemethod which only updates after- requestAnimationFrame.
- useSetState— creates- setStatemethod which works like- this.setState.
- useStateList— circularly iterates over an array.
- useToggleand- useBoolean— tracks state of a boolean.
- useCounterand- useNumber— tracks state of a number.
- useList~and- useUpsert~ — 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 the- useStateValidator, but tracks multiple states at a time.
- useMediatedState— like the regular- useStatebut with mediation by custom function.
- useFirstMountState— check if current render is first.
- useRendersCount— count component renders.
- createGlobalState— cross component shared state.
- useMethods— neat alternative to- useReducer.
 
- Miscellaneous- useEnsuredForwardedRefand- ensuredForwardRef— use a React.forwardedRef safely.