简体   繁体   中英

Redux ToolKit and React Native. Error: could not find react-redux context value;

I was following all the Quick Start tutorial for Redux Toolkit, but it's throws me the following error:

Error: could not find react-redux context value; please ensure the component is wrapped in a Provider

I don't know why, the Provider wrappe my App.js component and I dont use any Redux Hook inside the App component

This is my App component:

import React from "react";
import { NavigationContainer } from '@react-navigation/native';
import { createDrawerNavigator } from "@react-navigation/drawer";
import CustomDrawer from "./Components/CustomDrawer.jsx";
import Authentication from "./Pages/Authentication.jsx";
import Home from "./Pages/Home.jsx";
import { store } from "./Redux/Store.js";
import { Provider } from "react-redux";



const Drawer = createDrawerNavigator();


export default function App() {
  return (
    <Provider store={store}>
      <NavigationContainer>
        <Drawer.Navigator 
        screenOptions={{ 
          headerStyle: { 
            elevation: 0, 
            shadowOpacity: 0 
          }, 
          headerTransparent: true,
          headerTitle: '' 
        }} 
        drawerContent={(props) => <CustomDrawer  {...props} />}>

          <Drawer.Screen 
          name="Home" 
          component={Home} 
          />
          <Drawer.Screen 
          name="Register" 
          component={Authentication} 
          />
        </Drawer.Navigator>
      </NavigationContainer>
    </Provider>
  )
}

I have also seen the React Navigator documentation and it does not say anything about it.

Somehow I solved the bug.... All I did was reposition my Drawe.Screen components, refresh the application and then put them back as they were. I don't know what happened but somehow it fixed it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM