Skip to content

Commit

Permalink
Fix useAnimatedGestureHandler for web (#1518)
Browse files Browse the repository at this point in the history
## Description

For some time we were unable to use `react-native-web` above version `0.12.3`. Along with gesture handler `1.9.0`, this has been fixed as stated [here](software-mansion/react-native-gesture-handler#1164 (comment)).

It's required to pass a function on the web.

Fixes #1406 

## Changes

In Hooks.js instead of using `useEvent` on the web, we just return the handling function(also extract the `nativeEvent` in that case).
For example project, the package versions have been updated.

## Test code and steps to reproduce

Just run the example screens(like DragAndDrop or ChatHeads)

Co-authored-by: Jakub Gonet <[email protected]>
  • Loading branch information
karol-bisztyga and jakub-gonet authored Dec 10, 2020
1 parent 8638cdb commit db08e0f
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 100 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ jobs:
os: osx
xcode_workspace: './ios/ReanimatedExample.xcworkspace'
xcode_scheme: ReanimatedExample
xcode_sdk: iphonesimulator9.0
osx_image: xcode10.1
xcode_sdk: iphonesimulator12.4
osx_image: xcode12.2
podfile: './ios/Podfile'
xcode_destination: platform=iOS Simulator,OS=11.4,name=iPhone X
xcode_destination: platform=iOS Simulator,OS=12.2,name=iPhone X
env: NODE_VERSION=10.15.3

branches:
Expand All @@ -80,7 +80,7 @@ jobs:
- cd ios && pod install && cd ..

script:
- xcodebuild -workspace ./ios/ReanimatedExample.xcworkspace -scheme ReanimatedExample -configuration Debug -sdk iphonesimulator -derivedDataPath ./ios/build -quiet | egrep '^(/.+:[0-9+:[0-9]+:.error:|fatal|===)' || [[ $? == 1 ]] | uniq && exit ${PIPESTATUS[0]}
- xcodebuild -workspace ./ios/ReanimatedExample.xcworkspace -scheme ReanimatedExample -configuration Debug -sdk iphonesimulator -derivedDataPath ./ios/build -quiet | xcpretty

- language: node_js
node_js:
Expand Down
6 changes: 3 additions & 3 deletions Example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ PODS:
- ReactCommon/turbomodule/core (= 0.63.0)
- RNCMaskedView (0.1.10):
- React
- RNGestureHandler (1.8.0):
- React
- RNGestureHandler (1.9.0):
- React-Core
- RNReanimated (2.0.0-rc.0):
- DoubleConversion
- FBLazyVector
Expand Down Expand Up @@ -445,7 +445,7 @@ SPEC CHECKSUMS:
React-RCTVibration: 77ab1cf4a5eb854b88ad5ed3e9d8509ed124525e
ReactCommon: f63556ee9e41e9802257228237e5e660451a03cf
RNCMaskedView: 5a8ec07677aa885546a0d98da336457e2bea557f
RNGestureHandler: 7a5833d0f788dbd107fbb913e09aa0c1ff333c39
RNGestureHandler: 9b7e605a741412e20e13c512738a31bd1611759b
RNReanimated: b9c929bfff7dedc9c89ab1875f1c6151023358d9
RNScreens: 13f23e5498fb4aa749d19a5eda7f8792fbb9d01f
RNSVG: ce9d996113475209013317e48b05c21ee988d42e
Expand Down
4 changes: 2 additions & 2 deletions Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"react": "16.13.1",
"react-dom": "^16.13.1",
"react-native": "0.63.0",
"react-native-gesture-handler": "^1.8.0",
"react-native-gesture-handler": "^1.9.0",
"react-native-safe-area-context": "^3.1.1",
"react-native-screens": "^2.9.0",
"react-native-status-bar-height": "^2.4.0",
"react-native-svg": "^12.1.0",
"react-native-web": "^0.12.3",
"react-native-web": "^0.14.7",
"react-navigation": "^4.4.0",
"react-navigation-stack": "^2.8.2"
},
Expand Down
149 changes: 103 additions & 46 deletions Example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1882,18 +1882,30 @@
"@types/yargs" "^15.0.0"
chalk "^3.0.0"

"@react-native-community/cli-debugger-ui@^4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-4.9.0.tgz#4177764ba69243c97aa26829d59d9501acb2bd71"
"@react-native-community/cli-debugger-ui@^4.13.1":
version "4.13.1"
resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-4.13.1.tgz#07de6d4dab80ec49231de1f1fbf658b4ad39b32c"
integrity sha512-UFnkg5RTq3s2X15fSkrWY9+5BKOFjihNSnJjTV2H5PtTUFbd55qnxxPw8CxSfK0bXb1IrSvCESprk2LEpqr5cg==
dependencies:
serve-static "^1.13.1"

"@react-native-community/cli-platform-android@^4.7.0":
version "4.10.1"
resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-4.10.1.tgz#c326dfcce42acf106cc9c4afb95b360644fa595b"
integrity sha512-RawTRMd+pGQ/k+ZnZ/wTOcPd7sfbxkuhUmBoIthj8WJcufQdda57y/c6Cys9efAxKjvBP02RKX/Uhu+v7aS4jA==
"@react-native-community/cli-hermes@^4.13.0":
version "4.13.0"
resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-4.13.0.tgz#6243ed9c709dad5e523f1ccd7d21066b32f2899d"
integrity sha512-oG+w0Uby6rSGsUkJGLvMQctZ5eVRLLfhf84lLyz942OEDxFRa9U19YJxOe9FmgCKtotbYiM3P/XhK+SVCuerPQ==
dependencies:
"@react-native-community/cli-tools" "^4.10.1"
"@react-native-community/cli-platform-android" "^4.13.0"
"@react-native-community/cli-tools" "^4.13.0"
chalk "^3.0.0"
hermes-profile-transformer "^0.0.6"
ip "^1.1.5"

"@react-native-community/cli-platform-android@^4.13.0", "@react-native-community/cli-platform-android@^4.7.0":
version "4.13.0"
resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-4.13.0.tgz#922681ec82ee1aadd993598b814df1152118be02"
integrity sha512-3i8sX8GklEytUZwPnojuoFbCjIRzMugCdzDIdZ9UNmi/OhD4/8mLGO0dgXfT4sMWjZwu3qjy45sFfk2zOAgHbA==
dependencies:
"@react-native-community/cli-tools" "^4.13.0"
chalk "^3.0.0"
execa "^1.0.0"
fs-extra "^8.1.0"
Expand All @@ -1905,36 +1917,37 @@
xmldoc "^1.1.2"

"@react-native-community/cli-platform-ios@^4.7.0":
version "4.10.1"
resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-4.10.1.tgz#c73d7b33f22458aa806069df0dfc0ed55973679b"
integrity sha512-CiwAcZ0YZ5NBz6cKfa4MRFnPtTadRiy/A+kzaBUzsLXqV2qw5YIl08JEaxAI7sjuoi8/EE8CRCIkjlGYcqNK9Q==
version "4.13.0"
resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-4.13.0.tgz#a738915c68cac86df54e578b59a1311ea62b1aef"
integrity sha512-6THlTu8zp62efkzimfGr3VIuQJ2514o+vScZERJCV1xgEi8XtV7mb/ZKt9o6Y9WGxKKkc0E0b/aVAtgy+L27CA==
dependencies:
"@react-native-community/cli-tools" "^4.10.1"
"@react-native-community/cli-tools" "^4.13.0"
chalk "^3.0.0"
glob "^7.1.3"
js-yaml "^3.13.1"
lodash "^4.17.15"
plist "^3.0.1"
xcode "^2.0.0"

"@react-native-community/cli-server-api@^4.10.1":
version "4.10.1"
resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-4.10.1.tgz#6467c1c7e08bda068873bfd3c9d6ce112be969fa"
integrity sha512-GIueLxHr+qZhrSpwabbQuMMEAfdew38LmctYRuHVLOnsya0JZOvxehmD04aUrU54PaTPBj7Iidyrfd8fPDTaow==
"@react-native-community/cli-server-api@^4.13.1":
version "4.13.1"
resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-4.13.1.tgz#bee7ee9702afce848e9d6ca3dcd5669b99b125bd"
integrity sha512-vQzsFKD9CjHthA2ehTQX8c7uIzlI9A7ejaIow1I9RlEnLraPH2QqVDmzIdbdh5Od47UPbRzamCgAP8Bnqv3qwQ==
dependencies:
"@react-native-community/cli-debugger-ui" "^4.9.0"
"@react-native-community/cli-tools" "^4.10.1"
"@react-native-community/cli-debugger-ui" "^4.13.1"
"@react-native-community/cli-tools" "^4.13.0"
compression "^1.7.1"
connect "^3.6.5"
errorhandler "^1.5.0"
nocache "^2.1.0"
pretty-format "^25.1.0"
serve-static "^1.13.1"
ws "^1.1.0"

"@react-native-community/cli-tools@^4.10.1":
version "4.10.1"
resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-4.10.1.tgz#11f6833e646fbf53509282912e8d77658a8578b0"
integrity sha512-zGD0h+Ay8Rk8p+2wG41V163am8HfKkoZsVDKYkEKYD8O019if893pZyQ2sDcgk2ppNILrCt9O264dPDe/Ly1ow==
"@react-native-community/cli-tools@^4.13.0":
version "4.13.0"
resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-4.13.0.tgz#b406463d33af16cedc4305a9a9257ed32845cf1b"
integrity sha512-s4f489h5+EJksn4CfheLgv5PGOM0CDmK1UEBLw2t/ncWs3cW2VI7vXzndcd/WJHTv3GntJhXDcJMuL+Z2IAOgg==
dependencies:
chalk "^3.0.0"
lodash "^4.17.15"
Expand All @@ -1949,21 +1962,22 @@
integrity sha512-ael2f1onoPF3vF7YqHGWy7NnafzGu+yp88BbFbP0ydoCP2xGSUzmZVw0zakPTC040Id+JQ9WeFczujMkDy6jYQ==

"@react-native-community/cli@^4.7.0":
version "4.10.1"
resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-4.10.1.tgz#3c1e74f55c004936368d3576d4c1da7d02b89904"
integrity sha512-CtDer1sFxxPCvBBgmTbY5mjXgJiY/j7Nm7PzbbKxVBgpTkz5ZWP9B5e17lkmIweLqKDcM3hseCfsM/wG30fcLg==
version "4.13.1"
resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-4.13.1.tgz#60148723e77cafe3ae260317d6bffe91853a2d20"
integrity sha512-+/TeRVToADpQPSprsPkwi9KY8x64YcuJpjzMBVISwWP+aWzsIDuWJmyMXTADlCg2EBMJqJR7bn1W/IkfzVRCWA==
dependencies:
"@hapi/joi" "^15.0.3"
"@react-native-community/cli-debugger-ui" "^4.9.0"
"@react-native-community/cli-server-api" "^4.10.1"
"@react-native-community/cli-tools" "^4.10.1"
"@react-native-community/cli-debugger-ui" "^4.13.1"
"@react-native-community/cli-hermes" "^4.13.0"
"@react-native-community/cli-server-api" "^4.13.1"
"@react-native-community/cli-tools" "^4.13.0"
"@react-native-community/cli-types" "^4.10.1"
chalk "^3.0.0"
command-exists "^1.2.8"
commander "^2.19.0"
cosmiconfig "^5.1.0"
deepmerge "^3.2.0"
envinfo "^7.1.0"
envinfo "^7.7.2"
execa "^1.0.0"
find-up "^4.1.0"
fs-extra "^8.1.0"
Expand Down Expand Up @@ -3115,6 +3129,13 @@ create-react-class@^15.6.2:
loose-envify "^1.3.1"
object-assign "^4.1.1"

cross-fetch@^3.0.4:
version "3.0.6"
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.0.6.tgz#3a4040bc8941e653e0e9cf17f29ebcd177d3365c"
integrity sha512-KBPUbqgFjzWlVcURG+Svp9TlhA5uliYtiNx/0r8nv0pdypeQCRJ9IaSIc3q/x3q8t3F75cHuwxVql1HFGHCNJQ==
dependencies:
node-fetch "2.6.1"

cross-spawn@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
Expand Down Expand Up @@ -3207,11 +3228,6 @@ dayjs@^1.8.15:
version "1.8.16"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.8.16.tgz#2a3771de537255191b947957af2fd90012e71e64"

debounce@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/debounce/-/debounce-1.2.0.tgz#44a540abc0ea9943018dc0eaa95cce87f65cd131"
integrity sha512-mYtLl1xfZLi1m4RtQYlZgJUNQjl4ZxVnHzIR8nLLgi4q1YT8o/WM+MK/f8yfcc9s5Ir5zRaPZyZU6xs1Syoocg==

[email protected], debug@^2.1.2, debug@^2.2.0, debug@^2.3.3:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
Expand Down Expand Up @@ -3430,9 +3446,10 @@ entities@^2.0.0:
resolved "https://registry.yarnpkg.com/entities/-/entities-2.1.0.tgz#992d3129cf7df6870b96c57858c249a120f8b8b5"
integrity sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==

envinfo@^7.1.0:
version "7.3.1"
resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.3.1.tgz#892e42f7bf858b3446d9414ad240dbaf8da52f09"
envinfo@^7.7.2:
version "7.7.3"
resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.7.3.tgz#4b2d8622e3e7366afb8091b23ed95569ea0208cc"
integrity sha512-46+j5QxbPWza0PB1i15nZx0xQ4I/EfQxg9J8Had3b408SV63nEtor2e+oiY63amTo9KTuh2a3XLObNwduxYwwA==

error-ex@^1.3.1:
version "1.3.2"
Expand Down Expand Up @@ -3867,6 +3884,19 @@ fbjs@^1.0.0:
setimmediate "^1.0.5"
ua-parser-js "^0.7.18"

fbjs@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-3.0.0.tgz#0907067fb3f57a78f45d95f1eacffcacd623c165"
integrity sha512-dJd4PiDOFuhe7vk4F80Mba83Vr2QuK86FoxtgPmzBqEJahncp+13YCmfoa53KHCo6OnlXLG7eeMWPfB5CrpVKg==
dependencies:
cross-fetch "^3.0.4"
fbjs-css-vars "^1.0.0"
loose-envify "^1.0.0"
object-assign "^4.1.0"
promise "^7.1.1"
setimmediate "^1.0.5"
ua-parser-js "^0.7.18"

figures@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962"
Expand Down Expand Up @@ -4205,6 +4235,13 @@ hermes-engine@~0.5.0:
resolved "https://registry.yarnpkg.com/hermes-engine/-/hermes-engine-0.5.0.tgz#d914acce72e9657b3c98875ad3f9094d8643f327"
integrity sha512-jSuHiOhdh2+IF3bH2gLpQ37eMkdUrEb9GK6PoG3rLRaUDK3Zn2Y9fXM+wyDfoUTA3gz9EET0/IIWk5k21qp4kw==

hermes-profile-transformer@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/hermes-profile-transformer/-/hermes-profile-transformer-0.0.6.tgz#bd0f5ecceda80dd0ddaae443469ab26fb38fc27b"
integrity sha512-cnN7bQUm65UWOy6cbGcCcZ3rpwW8Q/j4OP5aWRhEry4Z2t2aR1cjrbp0BS+KiBN0smvP1caBgAuxutvyvJILzQ==
dependencies:
source-map "^0.7.3"

history@^4.7.2:
version "4.10.1"
resolved "https://registry.yarnpkg.com/history/-/history-4.10.1.tgz#33371a65e3a83b267434e2b3f3b1b4c58aad4cf3"
Expand Down Expand Up @@ -4405,6 +4442,11 @@ invariant@^2.2.4:
dependencies:
loose-envify "^1.0.0"

ip@^1.1.5:
version "1.1.5"
resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a"
integrity sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=

is-accessor-descriptor@^0.1.6:
version "0.1.6"
resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6"
Expand Down Expand Up @@ -5888,6 +5930,16 @@ nice-try@^1.0.4:
version "1.0.5"
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"

nocache@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/nocache/-/nocache-2.1.0.tgz#120c9ffec43b5729b1d5de88cd71aa75a0ba491f"
integrity sha512-0L9FvHG3nfnnmaEQPjT9xhfN4ISk0A8/2j4M37Np4mcDesJjHgEUfgPhdCyZuFI954tjokaIj/A3NdpFNdEh4Q==

[email protected]:
version "2.6.1"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==

node-fetch@^1.0.1:
version "1.7.3"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
Expand Down Expand Up @@ -6562,12 +6614,13 @@ react-is@^16.8.1, react-is@^16.8.4:
version "16.9.0"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.9.0.tgz#21ca9561399aad0ff1a7701c01683e8ca981edcb"

react-native-gesture-handler@^1.8.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-1.8.0.tgz#18f61f51da50320f938957b0ee79bc58f47449dc"
integrity sha512-E2FZa0qZ5Bi0Z8Jg4n9DaFomHvedSjwbO2DPmUUHYRy1lH2yxXUpSrqJd6yymu+Efzmjg2+JZzsjFYA2Iq8VEQ==
react-native-gesture-handler@^1.9.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-1.9.0.tgz#e441b1c0277c3fd4ca3e5c58fdd681e2f0ceddf0"
integrity sha512-fkkNeWDBzDdwDxDcxtYbrb9T1g0PLgT1AxBs2iO/p7uEbDbC6mIoL/NzuOnKNEBHcd0lpLoJuNmIfdmucEON5g==
dependencies:
"@egjs/hammerjs" "^2.0.17"
fbjs "^3.0.0"
hoist-non-react-statics "^3.3.0"
invariant "^2.2.4"
prop-types "^15.7.2"
Expand Down Expand Up @@ -6607,14 +6660,13 @@ react-native-svg@^12.1.0:
css-select "^2.1.0"
css-tree "^1.0.0-alpha.39"

react-native-web@^0.12.3:
version "0.12.3"
resolved "https://registry.yarnpkg.com/react-native-web/-/react-native-web-0.12.3.tgz#9f43301539672d46a302ee642afd29243a4376d5"
integrity sha512-6evhZl3tzYz5IUesbHEC4/ooUkXJPIAtrmDJWe3CdpDrV6rvBNNa1Utq192YKbHPzGtETuw+5X59K0O1n5EjWQ==
react-native-web@^0.14.7:
version "0.14.9"
resolved "https://registry.yarnpkg.com/react-native-web/-/react-native-web-0.14.9.tgz#ac968dd98e577ee655e0d270a858d6667fb8ce63"
integrity sha512-lrVSnzZuW+7xXQsjHFu1SGbd3XcgWaYUDNaJ9BF/eVypisQBlkagiJwpxBECcQjgMLz/ow8AmRSJCZtNuz73gA==
dependencies:
array-find-index "^1.0.2"
create-react-class "^15.6.2"
debounce "^1.2.0"
deep-assign "^3.0.0"
fbjs "^1.0.0"
hyphenate-style-name "^1.0.3"
Expand Down Expand Up @@ -7307,6 +7359,11 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"

source-map@^0.7.3:
version "0.7.3"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==

spdx-correct@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.0.0.tgz#05a5b4d7153a195bc92c3c425b69f3b2a9524c82"
Expand Down
Loading

0 comments on commit db08e0f

Please sign in to comment.