[英]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:我正在关注 Redux Toolkit 的所有快速入门教程,但它向我抛出了以下错误:
Error: could not find react-redux context value;错误:找不到 react-redux 上下文值; please ensure the component is wrapped in a Provider
请确保组件包装在 Provider 中
I don't know why, the Provider wrappe my App.js component and I dont use any Redux Hook inside the App component我不知道为什么,Provider 包装了我的 App.js 组件,我没有在 App 组件内使用任何 Redux Hook
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.我还看过 React Navigator 文档,但它没有说明任何内容。
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.不知何故我解决了这个错误......我所做的只是重新定位我的 Drawe.Screen 组件,刷新应用程序,然后将它们放回原样。 I don't know what happened but somehow it fixed it.
我不知道发生了什么,但它以某种方式修复了它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.