question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for nested reducerPaths for Redux-Toolkit-Query

See original GitHub issue

I have an application with lots of apis. As every api takes up a top-level property key in the store it will eventually create lots of clutter. As a short-term solution, I’ve temporarily prefixed the reducerPath so that they are presented next to one another when inspecting the store in DevTools (e.g. apis/pokemon), but this is not ideal. For example:

{
  apis/one: ...
  apis/two: ...
  apis/three: ...
  ...
  foo: ... (application stuff)
  bar: ... (application stuff)
}

Have you thought about this problem, and maybe the possibility to keep everything under a single key? For example apis? So you’d store the definitions like this:

{
  apis: {
    one: ...
    two: ... 
    ...
  } 
  foo: ... (application stuff)
  bar: ... (application stuff)
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
phryneascommented, Jun 23, 2021

No. Of course you can always try to write a wrapper around it, but honestly I would not care if I were you. That repeated word will gzip just fine to probably 1 or 2 bytes, so it won’t create any significant extra bundle size.

0reactions
mtodbergcommented, Jun 23, 2021

@phryneas By following this approach for code-splitting, is it possible to prefix all endpoints for a particular set of endpoints like /users/* or /companies/*? So every endpoint url in injectEndpoints is automatically prefixed with users or companies. Otherwise this identical information has to be repeated for every endpoint definition url. https://redux-toolkit.js.org/rtk-query/usage/code-splitting

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I get a nested array from an object using Redux ...
How can I get a nested array from an object using Redux toolkit query? according to documentation it says you can use transformResponse, ......
Read more >
Typescript error when adding RTK-Query middleware to a ...
I'm trying to add the RTK-Query middleware to a nested store structure, I'm getting a ... reducerPath] to the root of the reducer...
Read more >
Stepping up your Redux game with Redux Toolkit and ...
Here's how we can set up a basic API to fetch and update elements from a server. reducerPath is a unique key that...
Read more >
How to fetch data from api such that last created data comes ...
on using transformResponse() I am getting error TypeError: res.reverse is not a function import { createApi, fetchBaseQuery } ...
Read more >
createApi - Redux Toolkit
Define a service using a base URL and expected endpoints export const pokemonApi = createApi({ reducerPath: 'pokemonApi',
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found