Next.js Discord

Discord Forum

Using ReactQuery with Redux Toolkit in nextjs13 through an error

Unanswered
Cape lion posted this in #help-forum
Open in Discord
Cape lionOP
I am trying to fetch User data using redux toolkit RTQ its throw an error says
Error : could not find react-redux context value; please ensure the component is wrapped in a <Provider>

user slice.ts
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'

export const UserApi = createApi({
  reducerPath: 'User',
  baseQuery: fetchBaseQuery({ baseUrl: process.env.baseURL }),
  endpoints: (builder) => ({
    getUserDetail: builder.query({
      query: () => '/user/my-details',
    }),
  }),
})

export const { useGetUserDetailQuery } = UserApi
const UserReducer = UserApi.reducer
export default UserReducer

rootlayout
export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="en">
      <body className={poppins.className}>
        <ReduxProvider>
          <GoogleAuthProvider>
            {children}
          </GoogleAuthProvider>
        </ReduxProvider>
        <Toaster
          position="bottom-right"
          reverseOrder={false}
        />
      </body>
    </html>
  )
}

As this is all the setup that i can do from docs videos and stackoverflow issues but still can't fix the issues i am facing

0 Replies