Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Nasseratic
Copy link

@Nasseratic Nasseratic commented Sep 25, 2023

Hello 馃憢

closes: #111

There have been breaking changes with Expo 49 & expo-blur 12.4.1 see: expo/expo#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));

@spencerc99
Copy link

spencerc99 commented Sep 25, 2023

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

@Nasseratic
Copy link
Author

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 Nasseratic changed the title Expo 49 needed fixes Upgrade to Expo 49 & expo-blur 12.4.1 ( needed fixes ) Sep 26, 2023
@Nasseratic Nasseratic marked this pull request as ready for review September 26, 2023 21:19
@Nasseratic Nasseratic changed the title Upgrade to Expo 49 & expo-blur 12.4.1 ( needed fixes ) Upgrade to Expo 49 & expo-blur 12.4.1 ( with needed fixes for breaking changes ) Sep 26, 2023
@spencerc99
Copy link

spencerc99 commented Sep 27, 2023

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!

@simonwh
Copy link

simonwh commented Oct 16, 2023

Please merge this great PR maintainers 馃檹 @enesozturk @kesha-antonov @gorhom @spencerc99

@niraj-khatiwada
Copy link

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

@kesha-antonov
Copy link
Contributor

kesha-antonov commented Nov 24, 2023

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

@marcdelalonde
Copy link

marcdelalonde commented Dec 16, 2023

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 馃檹

@Nasseratic
Copy link
Author

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

@Martinnord
Copy link

Please merge 馃檹

@esorinas
Copy link

esorinas commented Mar 8, 2024

Thanks for the work done! Looking forward at this to be merged 馃槃

@tconroy
Copy link

tconroy commented Jun 21, 2024

@enesozturk could we merge this? 馃檹 the package is currently broken and this should fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expo 49 - Breaking Changes
10 participants