From d42b63cd67f71fe564be386fc4a8401d86111ff9 Mon Sep 17 00:00:00 2001 From: Tomek Zawadzki Date: Tue, 16 Aug 2022 10:34:02 +0200 Subject: [PATCH] Update NativeProxy.cpp (#3469) Fixes https://github.com/software-mansion/react-native-reanimated/issues/3351. --- android/src/main/cpp/NativeProxy.cpp | 6 +- react-native-reanimated-tests.tsx | 778 --------------------------- 2 files changed, 2 insertions(+), 782 deletions(-) delete mode 100644 react-native-reanimated-tests.tsx diff --git a/android/src/main/cpp/NativeProxy.cpp b/android/src/main/cpp/NativeProxy.cpp index 004b319489d..9db0ced9cab 100644 --- a/android/src/main/cpp/NativeProxy.cpp +++ b/android/src/main/cpp/NativeProxy.cpp @@ -40,10 +40,8 @@ NativeProxy::NativeProxy( layoutAnimations(std::move(_layoutAnimations)) {} NativeProxy::~NativeProxy() { - runtime_->global().setProperty( - *runtime_, - jsi::PropNameID::forAscii(*runtime_, "__reanimatedModuleProxy"), - jsi::Value::undefined()); + // removed temporary, new event listener mechanism need fix on the RN side + // reactScheduler_->removeEventListener(eventListener_); } jni::local_ref NativeProxy::initHybrid( diff --git a/react-native-reanimated-tests.tsx b/react-native-reanimated-tests.tsx deleted file mode 100644 index a227f70c8cf..00000000000 --- a/react-native-reanimated-tests.tsx +++ /dev/null @@ -1,778 +0,0 @@ -/* eslint-disable @typescript-eslint/no-empty-function */ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import React, { useState, useCallback, forwardRef } from 'react'; -import { - Text, - StyleSheet, - Button, - View, - Image, - FlatListProps, - ViewProps, - ImageProps, -} from 'react-native'; -import { - PanGestureHandler, - PinchGestureHandlerGestureEvent, - PinchGestureHandler, - PanGestureHandlerGestureEvent, - FlatList, -} from 'react-native-gesture-handler'; -import Animated, { - useSharedValue, - useDerivedValue, - useAnimatedStyle, - useAnimatedScrollHandler, - useAnimatedGestureHandler, - Easing, - withTiming, - withSpring, - cancelAnimation, - withDelay, - withRepeat, - withSequence, - withDecay, - useWorkletCallback, - runOnUI, - useAnimatedReaction, - interpolateColor, - makeMutable, - interpolateNode, - useValue, - color, - interpolateColors, - createAnimatedPropAdapter, - useAnimatedProps, - useAnimatedRef, - TimingAnimation, - SpringAnimation, - DecayAnimation, - DelayAnimation, - RepeatAnimation, - SequenceAnimation, - StyleLayoutAnimation, - Animation, - // eslint-disable-next-line import/no-unresolved -} from 'react-native-reanimated'; - -class Path extends React.Component<{ fill?: string }> { - render() { - return null; - } -} - -type Item = { - id: number; -}; - -const SomeFC = (props: ViewProps) => { - return ; -}; - -const SomeFCWithRef = forwardRef((props: ViewProps) => { - return ; -}); - -// Class Component -> Animated Class Component -const AnimatedPath = Animated.createAnimatedComponent(Path); -const AnimatedImage = Animated.createAnimatedComponent(Image); -const AnimatedFlatList = Animated.createAnimatedComponent(FlatList); -const AnimatedTypedFlatList = - Animated.createAnimatedComponent>(FlatList); - -// Function Component -> Animated Function Component -const AnimatedFC = Animated.createAnimatedComponent(SomeFC); -const AnimatedFCWithRef = Animated.createAnimatedComponent(SomeFCWithRef); - -function CreateAnimatedComponentTest1() { - const animatedProps = useAnimatedProps(() => ({ fill: 'blue' })); - return ( - - ); -} - -function CreateAnimatedComponentTest2() { - const animatedProps = useAnimatedProps(() => ({ fill2: 'blue' })); - return ( - // @ts-expect-error - - ); -} - -function CreateAnimatedComponentTest3() { - const animatedProps = useAnimatedProps( - () => ({ pointerEvents: 'none' } as const) - ); - return ( - - - - ); -} - -function CreateAnimatedFlatListTest1() { - const renderItem = useCallback( - ({ item, index }: { item: Item[]; index: number }) => { - if (Math.random()) { - return null; - } - return ; - }, - [] - ); - return ( - <> - - null} - /> - - - ); -} - -function CreateAnimatedFlatListTest2() { - return ( - <> - - // @ts-expect-error - data={[{ foo: 1 }]} - // @ts-expect-error - renderItem={({ item, index }) => } - /> - - data={[{ id: 1 }]} - renderItem={({ item, index }) => } - /> - - ); -} - -function TestClassComponentRef() { - const animatedRef = useAnimatedRef>(); - return ; -} - -function TestFunctionComponentRef() { - const animatedRef = useAnimatedRef>(); - return ( - - ); -} - -function TestFunctionComponentForwardRef() { - const animatedRef = useAnimatedRef>(); - return ; -} - -const styles = StyleSheet.create({ - container: { - flex: 1, - }, - box: { - height: 50, - backgroundColor: 'blue', - }, -}); - -/** - * Reanimated 1 - */ - -// @TODO: add reanimated 1 tests here - -/** - * Reanimated 2 Functions - */ - -// makeMutable -function MakeMutableTest() { - const mut = makeMutable(0); - const mut2 = makeMutable(true); - - return ; -} - -/** - * Reanimated 2 Hooks - */ - -// useSharedValue -function SharedValueTest() { - const translate = useSharedValue(0); - const translate2 = useSharedValue(0); - const translate3 = useSharedValue(0); - - const sharedBool = useSharedValue(false); - if (sharedBool.value) { - sharedBool.value = false; - } - - return ; -} - -// useAnimatedStyle -function AnimatedStyleTest() { - const width = useSharedValue(50); - const animatedStyle = useAnimatedStyle(() => { - return { - width: width.value, - }; - }); - return ; -} - -// useAnimatedStyle with arrays (invalid return) -function AnimatedStyleArrayTest() { - const width = useSharedValue(50); - // @ts-expect-error since the animated style cannot be an array. - const animatedStyle = useAnimatedStyle(() => { - return [styles.box, { width: width.value }]; - }); - return ; -} - -// useAnimatedStyle with null (invalid return) -function AnimatedStyleNullTest() { - const width = useSharedValue(50); - // @ts-expect-error since the animated style cannot be "false". - const animatedStyle = useAnimatedStyle(() => false); - return ; -} - -// useAnimatedStyle with number (invalid return) -function AnimatedStyleNumberTest() { - const width = useSharedValue(50); - // @ts-expect-error since the animated style cannot be a number. - const animatedStyle = useAnimatedStyle(() => 5); - return ; -} - -// useDerivedValue -function DerivedValueTest() { - const progress = useSharedValue(0); - const width = useDerivedValue(() => { - return progress.value * 250; - }); - // @ts-expect-error width is readonly - width.value = 100; - return ( -