React Native Drawer - Cannot read Property "isConfigured" of undefined & [Reanimated] Failed to create a worklet
Asked Answered
I

5

6

My Codes:

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 */
import React from 'react';
import { createDrawerNavigator} from '@react-navigation/drawer';
import { NavigationContainer } from '@react-navigation/native';
import StockRoom from './StockRoom';
const Drawer = createDrawerNavigator();

function Refill(navigation: any): React.JSX.Element {
  interface CustomAlertProps {
    show: boolean;
    onClose: () => void;
  }

  return (
    <NavigationContainer independent={true}>
      <Drawer.Navigator>
        <Drawer.Screen name="Home" component={StockRoom} />
      </Drawer.Navigator>
    </NavigationContainer>
    
  );
}


export default Refill;

First Error: enter image description here

Second Error: enter image description here

I need to create a simple drawer but i can't. How can i solve this two problem? I tried npm uninstall and download all packages again but doesn't work.

Innocent answered 25/1 at 12:18 Comment(1)
Facing the exact same issue with react native navigation Drawer.Navigator. were you able to find the probably cause for it, or were you able to fix it ?Breadstuff
D
8

Add this inside the your babel.config.js:

module.exports = {
  presets: ['module:@react-native/babel-preset'],
  plugins: ['react-native-reanimated/plugin']
};

After reconfiguring babel:

yarn start --reset-cache
Devries answered 28/1 at 8:32 Comment(0)
T
0

I had a very similar issue to this using React Navigation Stack Navigator. It went away for me by deleting node_modules, clearing npm and gradle build caches, reinstalling dependencies. Also, I had to add react-native-reanimated to my project dependencies. After doing this, things were working smooth as butter for me.

Hope this helps!

Triceps answered 25/1 at 12:27 Comment(1)
Doesn't work :/Innocent
P
0

The latest version of reanimated is not working properly with the drawer try to install this version of reaminated npm i [email protected]

Prickly answered 27/1 at 9:39 Comment(1)
[email protected] won't work with latest version of react nativeBreadstuff
D
0
I am also facing the same error and this is how i solved this error I'll guide you guy's step by step 

Step 1: Add Reanimated's babel plugin
Add react-native-reanimated/plugin plugin to your babel.config.js.

  

    module.exports = {
    presets: [
      ... // don't add it here :)
    ],
    plugins: [
      ...
      'react-native-reanimated/plugin',
    ],
  };

Step 2: Wrap metro config with reanimated wrapper (recommended)

Wrap your existing Metro configuration in the metro.config.js file with the wrapWithReanimatedMetroConfig function.

like this:

    const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
const {
  wrapWithReanimatedMetroConfig,
} = require('react-native-reanimated/metro-config');



Step 3: Clear Metro bundler cache (recommended)
npm start -- --reset-cache

these step are mandatory and also you can consider their official documentation here is the link:

https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/#step-3-wrap-metro-config-with-reanimated-wrapper-recommended

After that you can check these things also that config or not in your project..

react-native-screens package requires one additional configuration step to properly work on Android devices. Edit MainActivity.kt or MainActivity.java file which is located under android/app/src/main/java/<your package name>/.

Add the highlighted code to the body of MainActivity class:

  

      class MainActivity: ReactActivity() {
  // ...
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(null)
  }
  // ...
}

and make sure to add the following import statement at the top of this file below your package statement:

    import android.os.Bundle;


Step 4: Create Two Files in the Root of Your Project Directory

To finalize the installation of react-native-gesture-handler, we need to conditionally import it. To do this, create 2 files:

1. gesture-handler.native.js
// Only import react-native-gesture-handler on native platforms

    import 'react-native-gesture-handler';


2. gesture-handler.js
Leave this file empty 

Now, add the following at the top (make sure it's at the top and there's nothing else before it) of your entry file, such as index.js or App.js:

    import './gesture-handler';


To resolve this error, I recommend consulting the React Navigation documentation. By carefully following each step, you can likely avoid encountering the same issue. I faced a similar challenge, but after creating a new React Native project and successfully implementing drawer navigation by thoroughly studying the documentation, everything started working perfectly.
Duffel answered 20/10 at 14:4 Comment(0)
S
-1

Running a version of react-native-reanimated after 3.4.1, should have this issue fixed. Here is the change: https://github.com/software-mansion/react-native-reanimated/pull/4832

I had the same issue with reanimated 3.7.0 and fixed it by installing the necessary dependencies for react-native-reanimated/plugin listed here: https://github.com/software-mansion/react-native-reanimated/blob/main/plugin/README-dev.md

I also had to clean my project, do a brand new installation @react-navigation/drawer (including reanimated and react-native-gesture-handler) and rebuild the project. Hope this helps!

Suberin answered 12/2 at 10:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.