github toss/react-simplikit react-simplikit@0.3.0

5 hours ago

Minor Changes

  • #471 edddd4b Thanks @hyesungoh! - Add useDebouncedValue and useThrottledValue. Both take a value the caller owns and return a delayed copy of it: useDebouncedValue(value, wait, { leading?, trailing? }) follows the value wait milliseconds after the last change, and useThrottledValue(value, wait, { leading?, trailing? }) follows it at most once per wait milliseconds. They pair with the existing useDebouncedCallback and useThrottledCallback, which wrap a setter instead of a value.

  • #479 72ed16e Thanks @Antoliny0919! - Add lazy initializer support to useBooleanState.

  • #469 cc8b69e Thanks @DongEun02! - Add lazy initializer support to useInputState.

Patch Changes

  • #483 6605918 Thanks @chungyo! - Use the updated callback when useRefEffect dependencies change during DOM ref attachment.

  • #482 163ac5c Thanks @chungyo! - Fix useStorageState retaining stale state when another tab clears localStorage.

  • #470 52ed163 Thanks @hyesungoh! - useThrottle with edges: ['trailing'] now invokes once per wait while calls keep coming in, instead of waiting for the calls to stop. useThrottledCallback and useDebouncedCallback now keep a single throttle or debounce across calls: useThrottledCallback forwards a stream of distinct values at most once per timeThreshold instead of every time, and useDebouncedCallback with leading: true forwards the first value of a burst once instead of every value immediately. Sharing one instance has two further consequences. A call carrying the same value as the last forwarded one is still skipped, but it now occupies a window, so a different value arriving inside that window waits for the window to close. And changing timeThreshold, edges, leading or trailing while a value is pending discards that pending value instead of forwarding it. useImpressionRef and ImpressionArea inherit the useDebouncedCallback change: an impression that ends within timeThreshold of its start now reports onImpressionEnd on the trailing edge rather than immediately, and an end still pending when the element unmounts is emitted during cleanup instead of being dropped.

  • #467 92cbb34 Thanks @constantly-dev! - useIntersectionObserver no longer recreates the underlying IntersectionObserver on every render when an inline options object is passed. It now recreates it only when root, rootMargin, or threshold actually change.

  • #473 6f6361c Thanks @JetProc! - Cancel pending useLongPress timers when the component unmounts, preventing
    onLongPress from firing after unmount.

Don't miss a new react-simplikit release

NewReleases is sending notifications on new releases.