chore: configure reanimated 2

This commit is contained in:
Satyajit Sahoo
2021-04-04 06:52:31 +02:00
parent 1149e718c1
commit ef7370b215
3 changed files with 12 additions and 3 deletions

View File

@@ -2,5 +2,6 @@ module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: ['react-native-reanimated/plugin'],
};
};

View File

@@ -40,7 +40,11 @@ export type DrawerNavigationConfig = {
* The new implementation based on Reanimated 2 will perform better,
* but you need additional configuration and need to use Hermes with Flipper to debug.
*
* Defaults to `false` if Reanimated 2 is configured in the project, otherwise `true`.
* This defaults to `true` in following cases:
* - Reanimated 2 is not configured
* - App is connected to Chrome debugger (Reanimated 2 cannot be used with Chrome debugger)
*
* Otherwise, it defaults to `false`
*/
useLegacyImplementation?: boolean;
};

View File

@@ -77,8 +77,12 @@ function DrawerViewBase({
<DrawerContent {...props} />
),
detachInactiveScreens = true,
// @ts-expect-error: the type definitions are incomplete
useLegacyImplementation = !Animated.isConfigured?.(),
// Running in chrome debugger
// @ts-expect-error
useLegacyImplementation = !global.nativeCallSyncHook ||
// Reanimated 2 is not configured
// @ts-expect-error: the type definitions are incomplete
!Animated.isConfigured?.(),
}: Props) {
const Drawer: React.ComponentType<DrawerProps> = useLegacyImplementation
? require('./legacy/Drawer').default