react-native-hold-menu icon indicating copy to clipboard operation
react-native-hold-menu copied to clipboard

Upgrade to Expo 49 & expo-blur 12.4.1 ( with needed fixes for breaking changes )

Open Nasseratic opened this issue 1 year ago β€’ 11 comments

Hello πŸ‘‹

closes: #111

There have been breaking changes with Expo 49 & expo-blur 12.4.1 see: https://github.com/expo/expo/issues/23539

This PR bump expo + expo package versions and fix related breaking changes.

Unfortunately this library also breaks with reanimated 3.3.0 and 3.4.0. Not sure if it works with later versions or not. But there was a problem with assigning functions to a reanimated shared value ( when you try to read function after words it's always empty object) I could fix that with these changes that I found here:

diff --git a/src/reanimated2/shareables.ts b/src/reanimated2/shareables.ts
index 03575ab9e4f399a6a3a6fa6e7786b92b2c671830..1bf9451adcea074339105fef0c494b118c445385 100644
--- a/src/reanimated2/shareables.ts
+++ b/src/reanimated2/shareables.ts
@@ -21,6 +21,7 @@ const _shareableFlag = Symbol('shareable flag');
 const MAGIC_KEY = 'REANIMATED_MAGIC_KEY';
 
 function isHostObject(value: NonNullable<object>): boolean {
+  "worklet"
   // We could use JSI to determine whether an object is a host object, however
   // the below workaround works well and is way faster than an additional JSI call.
   // We use the fact that host objects have broken implementation of `hasOwnProperty`
@@ -257,6 +258,15 @@ export function makeShareableCloneOnUIRecursive<T>(value: T): ShareableRef<T> {
   function cloneRecursive<T>(value: T): ShareableRef<T> {
     const type = typeof value;
     if ((type === 'object' || type === 'function') && value !== null) {
+      // apply https://github.com/software-mansion/react-native-reanimated/commit/e76311f05c661787ffcc14bb9ab71d7403d680e7
+      // @ts-expect-error
+      if (value?.__remoteFunction) {
+        // @ts-expect-error
+        return value.__remoteFunction;
+      }
+      if (isHostObject(value as object)) {
+        return value as ShareableRef<T>;
+      }
       let toAdapt: any;
       if (Array.isArray(value)) {
         toAdapt = value.map((element) => cloneRecursive(element));

Nasseratic avatar Sep 25 '23 18:09 Nasseratic

awesome this works perfectly for me! thank you for publishing your latest changes :)

FYI I didn't need to apply that react-native-reanimated patch to get it to work but maybe i will run into the error later on

spencerc99 avatar Sep 25 '23 20:09 spencerc99

Maybe they merged the changes to the latest version? which version of reanimated are you using? 3.4.0? The issue should happen when trying to execute actions from the menu

Nasseratic avatar Sep 26 '23 08:09 Nasseratic

Maybe they merged the changes to the latest version? which version of reanimated are you using? 3.4.0? The issue should happen when trying to execute actions from the menu

Hmm I'm using 3.3.0 and I seem to be able to execute actions just fine from the simulator.. But I'm also not using any actionParams currently.

thanks again for your work on this!

spencerc99 avatar Sep 27 '23 16:09 spencerc99

Please merge this great PR maintainers πŸ™ @enesozturk @kesha-antonov @gorhom @spencerc99

simonwh avatar Oct 16 '23 08:10 simonwh

Hey maintainers, this seems to fix the issue. Please review and approve it when you get the time.

niraj-khatiwada avatar Oct 31 '23 12:10 niraj-khatiwada

@enesozturk please review changes, we also need rn-hold-menu in our project with expo 49+ and reanimated 3+

kesha-antonov avatar Nov 24 '23 08:11 kesha-antonov

Hey there πŸ‘‹,

It works on my side.

However, when I click on an action, I have this error: TypeError: item.onPress.apply is not a function (it is undefined)

The onPress does not seem to be pass down the good way within the component.

Any ideas?

Capture d’écran 2023-12-16 aΜ€ 22 33 35

Thank you πŸ™

marcdelalonde avatar Dec 16 '23 20:12 marcdelalonde

@marcdelalonde Did you try the reanimated patch I mentioned above?

Nasseratic avatar Dec 18 '23 08:12 Nasseratic

Please merge πŸ™

Martinnord avatar Dec 18 '23 19:12 Martinnord

Thanks for the work done! Looking forward at this to be merged πŸ˜„

esorinas avatar Mar 08 '24 16:03 esorinas

@enesozturk could we merge this? πŸ™ the package is currently broken and this should fix it.

tconroy avatar Jun 21 '24 04:06 tconroy