Skip to content

Commit

Permalink
Add number | null to ViewProps['hitSlop'] TypeScript type (#41070)
Browse files Browse the repository at this point in the history
Summary:
Setting the `hitSlop` of a `View` to be a `number` didn't work. The Flow type already allows `number`:
https://github.com/facebook/react-native/blob/6e42c98aa3423cfbc389e4fe877b5c6b559c8a81/packages/react-native/Libraries/Components/View/ViewPropTypes.js#L618

 I updated it to match the [`TouchableWithoutFeedbackProps['hitSlop']`](https://github.com/facebook/react-native/blob/6e42c98aa3423cfbc389e4fe877b5c6b559c8a81/packages/react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts#L72) and [`PressableProps['hitSlop']`](https://github.com/facebook/react-native/blob/6e42c98aa3423cfbc389e4fe877b5c6b559c8a81/packages/react-native/Libraries/Components/Pressable/Pressable.d.ts#L126) types.

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[GENERAL] [FIXED] Add `number | null` to `ViewProps['hitSlop']` TypeScript type

Pull Request resolved: #41070

Test Plan: Ran `yarn test-typescript` and `yarn test-typescript-offline` and there were no errors.

Reviewed By: rshest

Differential Revision: D50451318

Pulled By: javache

fbshipit-source-id: a0fceba270dbb80383cceb16f7719252a05b62b5
  • Loading branch information
DimitarNestorov authored and facebook-github-bot committed Oct 19, 2023
1 parent c068071 commit bc16bc5
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export interface ViewProps
* the Z-index of sibling views always takes precedence if a touch
* hits two overlapping views.
*/
hitSlop?: Insets | undefined;
hitSlop?: null | Insets | number | undefined;

/**
* Used to reference react managed views from native code.
Expand Down

0 comments on commit bc16bc5

Please sign in to comment.