-1

We're building a React.js web application, and we have been using RTK Query as a tool for API calls because it is convenient to use. However, we have noticed that the state of each API call is stored globally.

Given the large number of API calls we have, I am worried about the potential impact on performance.

Is there a way to use RTK Query without storing the state globally?

I tried to search for other ways but failed to find some answers.

  • Redux is a global state management library, so anything stored in it, including anything any RTKQ API slices store, will technically be "global". What specifically are you concerned would be an impact on performance? If the app needs to make/cache API queries, that data would need to be stored regardless. – Drew Reese Jun 07 '23 at 23:30
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jun 08 '23 at 07:14

1 Answers1

0

I think its doubtful since RTK Query "is an optional addon included in the Redux Toolkit package, and its functionality is built on top of the other APIs in Redux Toolkit" (https://redux-toolkit.js.org/rtk-query/overview).

By its nature, RTK Query is designed to work with Redux which in itself boasts "centralizing your application's state" as one of its core benefits. (https://redux.js.org/)

I'm not well-versed in app performance so I'm interested to hear some of the other comments on this thread as well, but wouldn't it be the same if you store response state local to a component like with an Axios call as it would if you stored it in Redux? We're not duplicating the state anywhere so aren't you just storing the response data once either way?