V2 to V3
[BREAKING CHANGE] Drop support for 'both' option in detect param
'both' option in detect paramReturning both mouse and touch handlers as a hook result caused unintended edge cases on touch devices that emulated clicks. Therefore 'both' value was removed and hook is now using 'pointer' as a default value for detect param.
This also enables to support more type of events in the future.
Pointer events should be sufficient replacement for 'both' option, but you can also programmatically detect if current device support touch events and set proper detect value based on that.
Before
const bind = useLongPress(() => console.log('Long pressed'), {
detect: 'both',
})After
const bind = useLongPress(() => console.log('Long pressed'), {
detect: 'pointer',
})[BREAKING CHANGE] Typings and param values
TypeScript's typings were refactored to use more consistent and precise names. Also changed callback reason values (see LongPressEventReason)
Changed generics order from
useLongPress<Target, Callback, Context>touseLongPress<Target, Context, Callback>Renamed
LongPressDetectEventsenum toLongPressEventTypeLongPressDetectEvents.MOUSE->LongPressEventType.MouseLongPressDetectEvents.TOUCH->LongPressEventType.Touch
Added
LongPressEventType.PointerRenamed
LongPressEventReasonenum toLongPressCallbackReasonLongPressEventReason.CANCELED_BY_MOVEMENT('canceled-by-movement') ->LongPressCallbackReason.CancelledByMovement('cancelled-by-movement')LongPressEventReason.CANCELED_BY_TIMEOUT('canceled-by-timeout') ->LongPressCallbackReason.CancelledByRelease('cancelled-by-release')
Removed
CoordinatestypeRenamed
EmptyObjecttype toLongPressEmptyHandlersRenamed
CallableContextResulttype toLongPressResultRenamed
LongPressResulttype toLongPressHandlersAdded mouse and touch handlers types -
LongPressMouseHandlersandLongPressTouchHandlers
Last updated
Was this helpful?