diff --git a/packages/react-native/Libraries/Pressability/Pressability.js b/packages/react-native/Libraries/Pressability/Pressability.js index 24f664c27da41f..940249af9a8df4 100644 --- a/packages/react-native/Libraries/Pressability/Pressability.js +++ b/packages/react-native/Libraries/Pressability/Pressability.js @@ -293,6 +293,7 @@ const DEFAULT_MIN_PRESS_DURATION = 130; const DEFAULT_LONG_PRESS_DEACTIVATION_DISTANCE = 10; let longPressDeactivationDistance = DEFAULT_LONG_PRESS_DEACTIVATION_DISTANCE; + /** * Pressability implements press handling capabilities. * @@ -313,7 +314,8 @@ let longPressDeactivationDistance = DEFAULT_LONG_PRESS_DEACTIVATION_DISTANCE; * bounds should trigger deactivation, but moving the same finger back within an * element's bounds should trigger reactivation. * - * In order to use `Pressability`, do the following: + * This should be consumed by functional components using `usePressability`. The + * following steps are only relevant for using `Pressability` in classes: * * 1. Instantiate `Pressability` and store it on your component's state. * @@ -330,7 +332,15 @@ let longPressDeactivationDistance = DEFAULT_LONG_PRESS_DEACTIVATION_DISTANCE; * * ); * - * 3. Reset `Pressability` when your component unmounts. + * 3. Update `Pressability` when your component mounts, updates, and unmounts. + * + * componentDidMount() { + * this.state.pressability.configure(...); + * } + * + * componentDidUpdate() { + * this.state.pressability.configure(...); + * } * * componentWillUnmount() { * this.state.pressability.reset(); diff --git a/packages/react-native/Libraries/Pressability/usePressability.js b/packages/react-native/Libraries/Pressability/usePressability.js index 3204711c9e5039..3f2aebb4461261 100644 --- a/packages/react-native/Libraries/Pressability/usePressability.js +++ b/packages/react-native/Libraries/Pressability/usePressability.js @@ -18,6 +18,13 @@ import {useEffect, useRef} from 'react'; * Creates a persistent instance of `Pressability` that automatically configures * itself and resets. Accepts null `config` to support lazy initialization. Once * initialized, will not un-initialize until the component has been unmounted. + * + * In order to use `usePressability`, do the following: + * + * const config = useMemo(...); + * const eventHandlers = usePressability(config); + * const pressableView = ; + * */ export default function usePressability( config: ?PressabilityConfig,