I created a store and authreducer and every thing works as expected
but when I add the useSelector
in app.js I get this error:
错误错误:找不到react-redux上下文值;请确保 该组件包裹在
<Provider>
中
(我曾try 在其他文件中使用useSelector
,没有任何错误.)
import { ApolloClient, ApolloProvider } from "@apollo/client";
import { Provider, useSelector } from "react-redux";
import Navigation from "./navigation";
import Navigation2 from "./navigation2";
import { store } from "./src/Redux/store";
import InMemoryCacheFct from "./src/apolloClient/InMemoryCache";
export default function App() {
// the err is when I add this line even he works in other files
const user = useSelector(state => state.auth.isAuthenticated);
const client = new ApolloClient({
uri: ".......serverUrl",
cache: InMemoryCacheFct(),
queryDeduplication: true,
});
return (
<ApolloProvider client={client}>
<Provider store={store}>
{user ? <Navigation /> : <Navigation2 />}
</Provider>
</ApolloProvider>
);
}