1,062 questions
Advice
0
votes
4
replies
80
views
How to access React context for base URL when creating Redux-Toolkit Query API slice?
I am trying to move to RTK Query, but am struggling with one thing - how to access React Context.
I currently am using custom hooks to query a back end. Depending on the environment (dev, uat, prod), ...
0
votes
2
answers
129
views
Using RTK Query to create a library for calls to my API
I have a REST API that I want to call from multiple React projects, and I was thinking to make a library that exposes the REST API calls, using the Redux Toolkit Query code generation.
I would like to ...
0
votes
1
answer
145
views
How to handle API error with a manual retry button without triggering infinite refetches?
I’m using RTK Query in a React component to fetch users:
function MyComponent() {
const {
data, isLoading, isError, isSuccess,
} = useGetUsersQuery();
if (isLoading) {
return <div&...
0
votes
2
answers
52
views
How to set state value live from react RTK Query?
Setting state value from RTK Query
Suppose you fetch some data with a RTK Query endpoint like in the website's example:
export function Posts() {
const { data : post, isFetching, isLoading } = ...
0
votes
0
answers
104
views
The request is frozen on the, {status: “pending”, isLoading: true, data: undefined}
The request is frozen on the pending status, the loading status does not change in the component {status: “pending”, isLoading: true, data: undefined}, I see the response in devTools and in my API, ...
1
vote
1
answer
70
views
Handling stale callbacks in unwrap of mutations
I have problems with understanding how to properly handle a case. Let's say we have a simplified component:
const XComponent = ({ aCallback }) => {
const [mutation] = useRtkQueryMutationHook()
...
-1
votes
1
answer
85
views
How can Redux-Toolkit Query send a variable to request headers?
I currently want to add meta data to the RKT Query request header and it's a variable. I want to pass it from the API request.
export const api = createApi({
reducerPath: 'api',
baseQuery: ...
2
votes
1
answer
98
views
How to use parametrized queries in selectors?
I'm working on a React app with Redux-Toolkit (RTK) Query. I need to fetch accounts from the server and then render them as well derive some data from them through a chain of selectors. If I fetch ...
1
vote
1
answer
85
views
rtk query and store management
I understand that RTK Query signifies a shift in thinking from Redux store / state management, and the general paradigm is that you use the RTK Query endpoint anytime you need data, and rely on it to ...
1
vote
1
answer
113
views
RTK Query Mutation with selector
I've used redux toolkit for a few years and I'm pretty familiar with it. I'm going through and attempting to update old code using the newer RTK Query strategy to replace some of my old slices and ...
0
votes
1
answer
213
views
RTKQuery with SignalR Websocket
I'm attempting to use RTK Query with a signalR websocket service to keep my react app up to date with server data.
My RTK API looks like this:
export const hubConnection = new signalR....
0
votes
0
answers
96
views
NextJS 15 - SSR fetching with RTK query & Redux
I'm having a little problem on my SSR calls for RTK query, they provide hooks to use but in the case of server side rendering, how do I fetch data via RTK query?
I could not find a solution for it and ...
1
vote
1
answer
295
views
How to get cached data in RTK-Query using useLazyQuery?
I am having issues understanding how to get useLazyQuery to get the cached data on a second time the component is mounted.
Imagine the following:
...
const [trigger, { data }] = api.useLazyQuery(); /...
0
votes
0
answers
113
views
How to Maintain Dynamic RTK Query Tag Validation and Invalidation for Multiple API Slices in Redux Toolkit?
I'm working on a project using Redux Toolkit (RTK) Query to manage multiple API endpoints, where each API slice is constructed dynamically through a function. My goal is to maintain a dynamic approach ...
1
vote
1
answer
220
views
RTK Query. How to handle path variable in baseUrl?
I need to make a request to a URL like this /common/path/:userId/specific/path/endpoints. /common/path is shared across many endpoints, and I don't want to put all of those queries in the same file. ...