@@ -29,27 +29,28 @@ let Reanimated: {
29
29
30
30
try {
31
31
Reanimated = require ( 'react-native-reanimated' ) ;
32
+ } catch ( e ) {
33
+ // When 'react-native-reanimated' is not available we want to quietly continue
34
+ // @ts -ignore TS demands the variable to be initialized
35
+ Reanimated = undefined ;
36
+ }
32
37
33
- if ( ! Reanimated . useSharedValue ) {
34
- // @ts -ignore Make sure the loaded module is actually Reanimated, if it's not
35
- // reset the module to undefined so we can fallback to the default implementation
36
- Reanimated = undefined ;
37
- throw new Error ( 'react-native-reanimated is not found' ) ;
38
- }
38
+ if ( ! Reanimated ?. useSharedValue ) {
39
+ // @ts -ignore Make sure the loaded module is actually Reanimated, if it's not
40
+ // reset the module to undefined so we can fallback to the default implementation
41
+ Reanimated = undefined ;
42
+ }
39
43
40
- if ( ! Reanimated . setGestureState ) {
41
- Reanimated . setGestureState = ( ) => {
42
- 'worklet' ;
43
- console . warn (
44
- tagMessage (
45
- 'Please use newer version of react-native-reanimated in order to control state of the gestures.'
46
- )
47
- ) ;
48
- } ;
49
- }
50
- // When 'react-native-reanimated' is not available we want to
51
- // quietly continue
52
- // eslint-disable-next-line no-empty
53
- } catch ( e ) { }
44
+ if ( Reanimated !== undefined && ! Reanimated . setGestureState ) {
45
+ // The loaded module is Reanimated but it doesn't have the setGestureState defined
46
+ Reanimated . setGestureState = ( ) => {
47
+ 'worklet' ;
48
+ console . warn (
49
+ tagMessage (
50
+ 'Please use newer version of react-native-reanimated in order to control state of the gestures.'
51
+ )
52
+ ) ;
53
+ } ;
54
+ }
54
55
55
56
export { Reanimated } ;
0 commit comments