github toss/react-simplikit react-simplikit@0.4.0

9 hours ago

Minor Changes

  • #574 402995e Thanks @DongEun02! - Pass the previous state value as the second argument to useInputState's transformValue callback.

  • #571 a62e7d6 Thanks @hyesungoh! - The emitted declarations of usePreservedCallback, useDebounce, useThrottle and useCallbackOncePerRender now name their callback parameter type CallerTypedArgs instead of any[]. It is the same type, so they accept the same callbacks. useThrottle also constrains the callback's return type to unknown instead of any, which accepts the same callbacks.

    The throttled function returned by useThrottle now accepts the callback's parameters instead of any[], so calling it with arguments the callback does not take is a type error. The return types of useThrottle and useDebounce are now written out in their declarations, so a consumer that emits declarations can export their result without a TS2742 error.

Patch Changes

  • #572 cf0dd83 Thanks @GamjaIsMine02! - Document that useOutsideClickEffect accepts null entries in container arrays, matching its existing type and behavior.

  • #569 8ead31d Thanks @GamjaIsMine02! - Mark useImpressionRef's rootMargin option as optional in the JSDoc and documentation, matching its existing type.

  • #575 5a21c39 Thanks @GamjaIsMine02! - Allow readonly arrays as the initial state and setAll input of useList.

  • #579 8828710 Thanks @KooYS! - useDoubleClick now runs click immediately for clicks that carry no click count (event.detail === 0), such as Enter/Space on a native button or a programmatic element.click(). The handler only recognised detail 1 and 2, so these clicks were dropped, and they also cancelled a pending mouse click. doubleClick is still only called for detail === 2.

  • #577 89ad72e Thanks @rjsgud49! - useLoading now keeps loading as true until every promise passed to startLoading has settled. Before, when two calls overlapped, the first promise to settle set loading to false while the other was still pending.

  • #576 7e8c88a Thanks @rjsgud49! - useLongPress no longer calls onClick twice for a tap on touch devices. After touchend, browsers fire emulated mousedown/mouseup events on the same element, and the hook handled them as a second, mouse press. That also called onClick after onLongPressEnd when the long press came from touch. Mouse presses that start within 1 second of a touch event are now ignored.

  • #567 d8e8147 Thanks @rjsgud49! - useScrollDirection no longer stops tracking scroll when throttleMs changes, or the component's effects re-run, while a throttle window is still open. The cleanup cleared the pending timer but left its id in the ref, so the next listener treated every scroll as throttled.

  • #578 4b9a4aa Thanks @mmporong! - Mark useMap's initialState parameter as optional in the JSDoc and documentation, matching its existing default of new Map().

Don't miss a new react-simplikit release

NewReleases is sending notifications on new releases.