react-native-hold-menu
react-native-hold-menu copied to clipboard
Upgrade to Expo 49 & expo-blur 12.4.1 ( with needed fixes for breaking changes )
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));
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
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
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!
Please merge this great PR maintainers π @enesozturk @kesha-antonov @gorhom @spencerc99
Hey maintainers, this seems to fix the issue. Please review and approve it when you get the time.
@enesozturk please review changes, we also need rn-hold-menu in our project with expo 49+ and reanimated 3+
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?
Thank you π
@marcdelalonde Did you try the reanimated patch I mentioned above?
Please merge π
Thanks for the work done! Looking forward at this to be merged π
@enesozturk could we merge this? π the package is currently broken and this should fix it.