Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError :subscriptionSelectorsRef?.current.isRequestSubscribed is not a function (it is undefined) in rtk-query-react.development.cjs #4257

Open
ashishimg27 opened this issue Mar 7, 2024 · 5 comments

Comments

@ashishimg27
Copy link

No description provided.

@ashishimg27 ashishimg27 changed the title TypeError :subscriptionSelectorsRef?.current.isRequestSubscribed is not a function (it is undefined) TypeError :subscriptionSelectorsRef?.current.isRequestSubscribed is not a function (it is undefined) in rtk-query-react.development.cjs Mar 7, 2024
@ashishimg27
Copy link
Author

ashishimg27 commented Mar 7, 2024

screenshot-1709804030791

i dont know what is cause of this error can anyone help me

@EskiMojo14
Copy link
Collaborator

have you definitely added the middleware for RTKQ to your store?

@ashishimg27
Copy link
Author

ashishimg27 commented Mar 8, 2024

@EskiMojo14 yes
store file code -

import { configureStore } from "@reduxjs/toolkit";
import { setupListeners } from "@reduxjs/toolkit/query";

import rootReducer from "app/redux/reducers";
import validateDomainMiddleware from "app/redux/middellware/domain";
import validateSignInWithCredential from "app/redux/middellware/signIn";
import { feeds } from "app/redux/reducers/app/feeds";
import { userById } from "app/redux/reducers/app/user";
import { chats } from "app/redux/reducers/app/chat";
import userSignInMiddleware from "app/redux/middellware/user";
import { profile } from "app/redux/reducers/app/profile";
import rtkQueryErrorLogger from "app/redux/middellware/error";

export const store = configureStore({
  reducer: rootReducer,
  middleware: (getDefaultMiddleware) =>
    getDefaultMiddleware({ serializableCheck: false }).concat(
      validateDomainMiddleware,
      userSignInMiddleware,
      validateSignInWithCredential,
      rtkQueryErrorLogger,
      feeds.middleware,
      userById.middleware,
      chats.middleware,
      profile.middleware
    ),
});

setupListeners(store.dispatch);

@haasampath
Copy link

Please check your middleware order, that can be matters, i have had the similar experience...

@EskiMojo14
Copy link
Collaborator

i think middleware order shouldn't matter as long as every middleware definitely returns the result of calling next(action) (apart from cases where it's specifically intending to return something different)

const brokenMiddleware = api => next => action => {
  console.log(api.getState())
  next(action)
  console.log(api.getState())
}

const workingMiddleware = api => next => action => {
  console.log(api.getState())
  const result = next(action)
  console.log(api.getState())
  return result
}

you should also make sure no middleware is marked with the async keyword, which will cause every dispatch result to be wrapped in a promise

const brokenMiddleware2 = api => next => async action => {
  console.log(api.getState())
  const result = next(action)
  console.log(api.getState())
  return result
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants