Ошибка: не удалось найти значение контекста react-redux; пожалуйста, убедитесь, что компонент обернут в <Provider>: В моем React Native, Django-restframework
Я настроил свой RTK запрос в React Native (expo-router)/File based here files
rtk/api.ts:
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
export const api = createApi({
baseQuery: fetchBaseQuery({ baseUrl: "http://127.0.0.1:8000/" }),
endpoints: (builder) => ({
signUp: builder.mutation({
query: (userData) => ({
url: "accounts/signup/",
method: "POST",
body: userData,
}),
}),
login: builder.mutation({
query: (credentials) => ({
url: "accounts/login/",
method: "POST",
body: credentials,
}),
}),
logout: builder.mutation({
query: () => ({
url: "accounts/logout/",
method: "POST",
}),
}),
passwordReset: builder.mutation({
query: (data) => ({
url: "accounts/password_reset/",
method: "POST",
body: data,
}),
}),
passwordResetConfirm: builder.mutation({
query: (data) => ({
url: `accounts/password_reset_confirm/${data.uidb64}/${data.token}/`,
method: "POST",
body: data,
}),
}),
changePassword: builder.mutation({
query: (data) => ({
url: "accounts/change_password/",
method: "POST",
body: data,
}),
}),
userVerification: builder.mutation({
query: (data) => ({
url: "accounts/user_verification/",
method: "POST",
body: data,
}),
}),
userVerificationConfirm: builder.mutation({
query: (data) => ({
url: `accounts/user_verification_confirm/${data.idb64}/${data.token}/`,
method: "POST",
body: data,
}),
}),
addPhone: builder.mutation({
query: (data) => ({
url: "accounts/phone/add/",
method: "POST",
body: data,
}),
}),
addEmail: builder.mutation({
query: (data) => ({
url: "accounts/email/add/",
method: "POST",
body: data,
}),
}),
}),
});
export const {
useSignUpMutation,
useLoginMutation,
useLogoutMutation,
usePasswordResetMutation,
usePasswordResetConfirmMutation,
useChangePasswordMutation,
useUserVerificationMutation,
useUserVerificationConfirmMutation,
useAddPhoneMutation,
useAddEmailMutation,
} = api;
rtk/store.ts
import { configureStore } from "@reduxjs/toolkit";
import { api } from "./api";
export const store = configureStore({
reducer: {
[api.reducerPath]: api.reducer,
},
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware().concat(api.middleware),
});
app/index.tsx
import { Text, View } from "react-native";
import { Provider } from "react-redux";
import { store } from "../../rtk/store";
import { Link } from "expo-router";
export default function Index() {
return (
<Provider store={store}>
<View className="flex-1 items-center justify-center bg-slate-200">
<Text>Farmlink World</Text>
<Link href="register" className="text-blue-500">
Signup Today
</Link>
<Link href="login" className="text-blue-500">
Login to explore
</Link>
</View>
</Provider>
);
}
Вот ошибка, которую я получаю: ` ERROR Error: could not find react-redux context value; please ensure the component is wrapped in a