Minor Changes
-
#471
edddd4bThanks @hyesungoh! - AdduseDebouncedValueanduseThrottledValue. Both take a value the caller owns and return a delayed copy of it:useDebouncedValue(value, wait, { leading?, trailing? })follows the valuewaitmilliseconds after the last change, anduseThrottledValue(value, wait, { leading?, trailing? })follows it at most once perwaitmilliseconds. They pair with the existinguseDebouncedCallbackanduseThrottledCallback, which wrap a setter instead of a value. -
#479
72ed16eThanks @Antoliny0919! - Add lazy initializer support to useBooleanState. -
#469
cc8b69eThanks @DongEun02! - Add lazy initializer support to useInputState.
Patch Changes
-
#483
6605918Thanks @chungyo! - Use the updated callback when useRefEffect dependencies change during DOM ref attachment. -
#482
163ac5cThanks @chungyo! - FixuseStorageStateretaining stale state when another tab clears localStorage. -
#470
52ed163Thanks @hyesungoh! -useThrottlewithedges: ['trailing']now invokes once perwaitwhile calls keep coming in, instead of waiting for the calls to stop.useThrottledCallbackanduseDebouncedCallbacknow keep a single throttle or debounce across calls:useThrottledCallbackforwards a stream of distinct values at most once pertimeThresholdinstead of every time, anduseDebouncedCallbackwithleading: trueforwards 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 changingtimeThreshold,edges,leadingortrailingwhile a value is pending discards that pending value instead of forwarding it.useImpressionRefandImpressionAreainherit theuseDebouncedCallbackchange: an impression that ends withintimeThresholdof its start now reportsonImpressionEndon the trailing edge rather than immediately, and an end still pending when the element unmounts is emitted during cleanup instead of being dropped. -
#467
92cbb34Thanks @constantly-dev! -useIntersectionObserverno longer recreates the underlyingIntersectionObserveron every render when an inlineoptionsobject is passed. It now recreates it only whenroot,rootMargin, orthresholdactually change. -
#473
6f6361cThanks @JetProc! - Cancel pending useLongPress timers when the component unmounts, preventing
onLongPress from firing after unmount.