react-native-reanimated: Can't be used with React Navigation/Drawer V6
Description
Can’t be used with Drawer Navigator in React Navigation.
Expected behavior
Able to create and use Drawer Navigator with no exception.
Actual behavior & steps to reproduce
Just trying to create Drawer object.
import {createDrawerNavigator} from '@react-navigation/drawer';
const Drawer = createDrawerNavigator();
And it throws an error.
ERROR TypeError: null is not an object (evaluating '_ReanimatedModule.default.createNode')
ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
Snack or minimal code example
// source: https://reactnavigation.org/docs/drawer-based-navigation
import * as React from 'react';
import {Button, View} from 'react-native';
import {createDrawerNavigator} from '@react-navigation/drawer';
import {NavigationContainer} from '@react-navigation/native';
function HomeScreen({navigation}) {
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<Button
onPress={() => navigation.navigate('Notifications')}
title="Go to notifications"
/>
</View>
);
}
function NotificationsScreen({navigation}) {
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<Button onPress={() => navigation.goBack()} title="Go back home" />
</View>
);
}
const Drawer = createDrawerNavigator(); // error
export default function App() {
return (
<NavigationContainer>
<Drawer.Navigator initialRouteName="Home">
<Drawer.Screen name="Home" component={HomeScreen} />
<Drawer.Screen name="Notifications" component={NotificationsScreen} />
</Drawer.Navigator>
</NavigationContainer>
);
}
Package versions
- React Native: 0.65.1
- React Native Reanimated: 2.2.0
- React Navigation Drawer: 6.1.4
- React Navigation Native: 6.0.2
- React Navigation Gesture Handler: 1.10.3
- NodeJS: v16.6.2
- Xcode:
- Java & Gradle: 11.0.12
Affected platforms
- Android
- iOS
- Web
Temporary Resolve Method
It works with "react-native-reanimated": "^1.13.2"
.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 23
- Comments: 34 (7 by maintainers)
Commits related to this issue
- Downgrade all related navigation packages. react-native-reanimated 2+ has a known of issue of not working well with @react-navigation/drawer which requires reanimated. Downgrading Reanimated is not e... — committed to mark-yacoub/metremenqeemi by deleted user 2 years ago
- Downgrade all related navigation packages. react-native-reanimated 2+ has a known of issue of not working well with @react-navigation/drawer which requires reanimated. Downgrading Reanimated is not e... — committed to mark-yacoub/metremenqeemi by deleted user 2 years ago
This worked for me.
npm i react-native-reanimated
plugins: ['react-native-reanimated/plugin'],
below presets in ‘<your_app_root_folder>/babel.config.js’.import 'react-native-gesture-handler';
to the top of ‘<your_app_root_folder>/App.js’.npx react-native start --reset-cache
.Hey @efefurkankarakaya
We are working on a solution to this problem.
How to solve this error without downgrading react-native-reanimated
Temporary solution / resolve method as I mentioned in the main post is
Can be installed with
npm install react-native-reanimated@1.13.2
Stuck at this for weeks… any temporary solution?
Clearing the cache after upgrading from
react-native-reanimated@1.13.2
helped in my case: Just rannpm start -- --reset-cache
and the error disappeared.@piaskowyk all good, the issue seemed to be something from my end.
I was using
"@react-navigation/drawer": "^6.6.0"
with"react-native-reanimated": "^3.0.0"
. These were the fixes for me:To sum up: I understand that the repo where the issue can be reproduced is here: https://github.com/efefurkankarakaya/react-native-reanimated-reproduction
Can you update the issue description such that all up-to-date information is in one place?
@InterstateTAT make sure that the libraries have really been updated on the Java side
autolinking
solved the issue for meActually, I’ve just tried it again and this error still exist with the newest version of React Native and React Navigation.
Error log:
Full
package.json
of current status.But it doesn’t throw an error with
react-native-reanimated@1.13.2
, works well.Full package.json of working situation is above.
By the way this project does not have anything but App.js and I’ve already specified where I took it from the code but of course, I’ll share it as a repository.
Working version @1.13.2 reproduction: https://github.com/efefurkankarakaya/react-native-reanimated-1.13.2-reproduction Faulty / not working version reproduction: https://github.com/efefurkankarakaya/react-native-reanimated-reproduction