Skip to content

Commit

Permalink
mark 'force' as optional property of PressEvent object (#29006)
Browse files Browse the repository at this point in the history
Summary:
Refs:
* https://github.com/facebook/react-native/blob/master/React/Fabric/RCTSurfaceTouchHandler.mm#L93
* https://github.com/facebook/react-native/blob/master/RNTester/js/examples/Pressable/PressableExample.js#L25

According to the current implementation `force` will be returned only on `iOS` platform, only on the devices which have a hardware 3D touch capabilities.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General] [Fixed] - mark `force` as an optional property of the PressEvent object
Pull Request resolved: #29006

Test Plan: Go CI!

Reviewed By: cpojer

Differential Revision: D21797241

Pulled By: TheSavior

fbshipit-source-id: e66be6958a2251bc8585e87e6bad54484a067949
  • Loading branch information
Simek authored and facebook-github-bot committed May 30, 2020
1 parent f29238c commit ad2f98d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Libraries/Types/CoreEventTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export type TextLayoutEvent = SyntheticEvent<
export type PressEvent = ResponderSyntheticEvent<
$ReadOnly<{|
changedTouches: $ReadOnlyArray<$PropertyType<PressEvent, 'nativeEvent'>>,
force: number,
force?: number,
identifier: number,
locationX: number,
locationY: number,
Expand Down
2 changes: 1 addition & 1 deletion RNTester/js/examples/Pressable/PressableExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function ForceTouchExample() {
style={styles.wrapper}
testID="pressable_3dtouch_button"
onStartShouldSetResponder={() => true}
onResponderMove={event => setForce(event.nativeEvent.force)}
onResponderMove={event => setForce(event.nativeEvent?.force || 1)}
onResponderRelease={event => setForce(0)}>
<Text style={styles.button}>Press Me</Text>
</View>
Expand Down

0 comments on commit ad2f98d

Please sign in to comment.