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

RTK query: Error with the name of the hooks #4220

Closed
JanselLopez opened this issue Feb 18, 2024 · 1 comment
Closed

RTK query: Error with the name of the hooks #4220

JanselLopez opened this issue Feb 18, 2024 · 1 comment

Comments

@JanselLopez
Copy link

If I declare two with the same name on the endpoint, even if they are imported from different files, it takes it as if it were the same and keeps the first one that makes a request and the second no longer makes it.

Example:
In ‘/products.js’
const productsApi = baseApi.injectEndpoints ({
endpoints: builder => ({
getProducts: ...
})
})

export const {
useGetProductsQuery,
….
} = productsApi;

In ’/stats.js’
const statsApi = baseApi.injectEndpoints ({
endpoints: builder => ({
getProducts: ...
})
})

export const {
useGetProductsQuery,
….
} = statsApi;

@EskiMojo14
Copy link
Collaborator

this is intended and documented behaviour. in development mode, you'll get a warning in console about it. remember, you're injecting into the same api instance, not creating a new one.

see #3350 for further discussion of this.

@EskiMojo14 EskiMojo14 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 18, 2024
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

2 participants