Skip to content

Commit

Permalink
Remove unnecessary throw (#2446)
Browse files Browse the repository at this point in the history
## Description

Removes redundant `throw` as it was inside `try...catch` anyway.
  • Loading branch information
j-piasecki committed Apr 25, 2023
1 parent a8d17fa commit 5a680d8
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions src/handlers/gestures/reanimatedWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,28 @@ let Reanimated: {

try {
Reanimated = require('react-native-reanimated');
} catch (e) {
// When 'react-native-reanimated' is not available we want to quietly continue
// @ts-ignore TS demands the variable to be initialized
Reanimated = undefined;
}

if (!Reanimated.useSharedValue) {
// @ts-ignore Make sure the loaded module is actually Reanimated, if it's not
// reset the module to undefined so we can fallback to the default implementation
Reanimated = undefined;
throw new Error('react-native-reanimated is not found');
}
if (!Reanimated?.useSharedValue) {
// @ts-ignore Make sure the loaded module is actually Reanimated, if it's not
// reset the module to undefined so we can fallback to the default implementation
Reanimated = undefined;
}

if (!Reanimated.setGestureState) {
Reanimated.setGestureState = () => {
'worklet';
console.warn(
tagMessage(
'Please use newer version of react-native-reanimated in order to control state of the gestures.'
)
);
};
}
// When 'react-native-reanimated' is not available we want to
// quietly continue
// eslint-disable-next-line no-empty
} catch (e) {}
if (Reanimated !== undefined && !Reanimated.setGestureState) {
// The loaded module is Reanimated but it doesn't have the setGestureState defined
Reanimated.setGestureState = () => {
'worklet';
console.warn(
tagMessage(
'Please use newer version of react-native-reanimated in order to control state of the gestures.'
)
);
};
}

export { Reanimated };

0 comments on commit 5a680d8

Please sign in to comment.