Support onPress/onLongPress in usePressableState #1061
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Platforms Impacted
Description of changes
Related: #1035
With #863 , we introduced the hook "usePressableState" as a first step to get us off our local version of Pressable, and to use the stock React Native component instead. I'm working on completing that work for my FHL project (a week long hackathon at Microsoft). I'm working through all the issues of using the new hook vs the old one (useAsPressable). To start with, I'll start with a simple and easy fix:
To start with, I noticed that we don't pass "onPress/onLongPress" as callbacks into usePressHelper, which is used by usePressState. Thus, any of the components I tried to switch to use this new hook didn't actually execute their onPress props. We should just fix this by extending usePressHelper to support onPress/onLongPress on top of onPressIn/onPressOut.
Other things I did:
interactive-hooks.api.md
. This is a leftover file from Remove api extractor #854 where we forgot to remove this file.Verification
Locally switched components like Button and Checkbox to use the new hook and verified that their onPress callback was called.
Pull request checklist
This PR has considered (when applicable):