Questions tagged [rtk-query]

Redux toolkit query is for data and caching in a web application. It is an optional add-on in the Redux toolkit package.

RTK Query offers a set of powerful features that help developers handle common tasks related to data fetching, caching, and synchronization with the server. Some key features of RTK Query include:

  • Automatic API request generation: RTK Query generates API request endpoints based on a configuration object that defines the URL, method, headers, and other options. It eliminates the need to write boilerplate code for making API requests.

  • Automatic caching and invalidation: RTK Query automatically caches API responses, allowing subsequent requests for the same data to be served from the cache. It also provides mechanisms for cache invalidation when the data on the server changes.

  • Data synchronization: RTK Query handles data synchronization between the client and server, ensuring that the local data remains up-to-date with the server data. It supports background data fetching and real-time updates through WebSockets.

    Advanced data manipulation and normalization: RTK Query provides built-in support for data manipulation and normalization, allowing you to transform and shape the API responses before storing them in the cache.

  • Integration with Redux: RTK Query seamlessly integrates with Redux, leveraging the Redux store for storing the cached data and managing the state of ongoing API requests. It works well alongside other Redux Toolkit features, such as the Redux store, reducers, and middleware.

Overall, RTK Query aims to simplify the process of managing remote data in a Redux-based application by providing a standardized and efficient way to handle data fetching, caching, and synchronization.

You can learn more about RTK Query and its usage in the official documentation: RTK Query

948 questions
-1
votes
4 answers

React useEffect: how prevent a RTK query mutation to be executed twice?

I have this Component: /* eslint-disable */ import React, { useEffect, useState } from "react"; import { usePostValidateMutation } from "./features/apiSlice"; export const App = () => { const [postValidate] = usePostValidateMutation(); const…
sineverba
  • 5,059
  • 7
  • 39
  • 84
-1
votes
1 answer

RTK Query | Non-Serializable Date Query Args

I would like to supply Dates as arguments to my RTK Queries. For instance, I have an interface like so that I supply to my queries: export interface ScheduleIdentifier { code: string; date: Date; } I have endpoints like so that take a Date (via…
-1
votes
1 answer

Reduce unused Javascript in CRA method

after build build\static\js How to split this file or reduce file size to improve page speed Screenshot: Reduce unused JavaScript Removed unused imports, dead code , unused CSS, uninstalled unused packages from Package.json file
-1
votes
1 answer

Is it possible to use RTK Query without storing the results and response in the global state?

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…
-1
votes
1 answer

RTK Query: How to invalidate a tag with different params?

Here's my scenario, I have an infinite scroll list in React Native that I implemented with RTK Query using merge and forceRefetch, each time the user scrolls down to the bottom of the list I increment the current page number which will trigger a new…
abdou-tech
  • 687
  • 1
  • 8
  • 16
-1
votes
1 answer

How can I trigger RTK Query reuqest if some slice's state has been changed?

I'm using RTK Query in my app. I have some filters on a page. I want to keep them in store so that if I leave page and come back they would stay the same. So when user changes them in select dropdowns app dispatches some reducer's action. How can I…
PttRulez
  • 115
  • 7
-1
votes
1 answer

TypeError: Converting circular structure to JSON - Socket.IO Client

I use Socket IO with RTK Query and Redux-Toolkit, I have a problem when add Socket like a arg to endpoints RTK-QUERY. How can I fix it? How can I fix this problem?
-1
votes
2 answers

Cannot read properties of undefined (reading 'navigation')

Unhandled Runtime Error TypeError: Cannot read properties of undefined (reading 'navigation') onSwiper={(swiper) => { setTimeout(() => { swiper.params.navigation.prevEl = navigationPrevRef.current; …
-1
votes
1 answer

Possible Unhandled Promise Rejection (id: 0) on RTK QUERY

Why I get this error on RTK Query when using onQueryStarted ? When I remove onQueryStarted then it works... Possible Unhandled Promise Rejection (id: 0): TypeError: Cannot destructure undefined import { createApi, fetchBaseQuery } from…
locklock123
  • 197
  • 1
  • 13
-1
votes
1 answer

In rtk query can i only use selectFromResult in a component that is a child or can it be used anywhere?

I am using next with rtk query. I have this query getPosts where I fetch and display the posts now when I click on a single post a new page opens and I want to use selectFromResult here to select the post I want from getPosts data. Is this possible…
H.b
  • 239
  • 2
  • 13
-1
votes
1 answer

How can I ensure the refresh of a sub component's props?

I have a problem with RTK queries : I have a first component that encapsulates a table. When a refresh occurs - for example when I delete some data - the parent component receives the data and passes it to the child through props but the Table is…
Tibo
  • 621
  • 1
  • 8
  • 24
-1
votes
1 answer

Insert array of items to database one by one

I have an array of items that I want to insert into the database one after another, something like this: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}] so basically, there would be a for..of loop iterating over this array and…
Normal
  • 1,616
  • 15
  • 39
-1
votes
1 answer

Sorting utility function not working as intended

So I'm creating a web app using react with typescript that calls an api endpoint (it's a yugioh card database https://db.ygoprodeck.com/api-guide/). I should probably also point out that I'm using RTK Query, it might be a caching things I don't…
Benji
  • 61
  • 6
-1
votes
1 answer

How to prepare $_POST in PHP with Redux Toolkit Query

I am trying to experiment with Redux Toolkit Query mutations. What I have now at the front-end: import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; export const postApi = createApi({ reducerPath: "postApi", baseQuery:…
Chong Lip Phang
  • 8,755
  • 5
  • 65
  • 100
-1
votes
3 answers

TypeError: inject.endpoints is not a function

I was reading RTK Query Quick Start tutorial and was trying it in javascript while running it shown me this error. Example at the corresponding site has shown both Typescript and Javascript code, but sandbox example is in…
Abdul Qadir Memon
  • 950
  • 1
  • 12
  • 27
1 2 3
63
64