All Questions
Tagged with rtk-query react-hooks
51 questions
1
vote
1
answer
84
views
Redux-Toolkit (RTK) Query get mutation endpoint loading state
I have a component (like a dialog box) that provides the Submit button. This dialog component then renders a form component.
Form component includes all the fields and also RTK Query to send the ...
2
votes
1
answer
74
views
Redux-Toolkit-Query: polling, selectfromReult with selectors
I am using below Redux-Toolkit Query (RTKQ) hooks to get information from one of the API and polling this for every 5 seconds, and selectFromResult to get the desired data.
const selectorData = ...
2
votes
1
answer
44
views
Conditional api endpoints for different tables react-redux
I have am edit component that should be used for three of the tables in my database. However I'm running into React Hook is called conditionally. I want the conditional hooks because the table that is ...
0
votes
1
answer
36
views
Looses focus after write one word in input when use UseSelctor. why?
Here is parent and child. i use UseSelector to get state and pass it child component. But when i write something in input it looses the focus. why?
enter image description here
enter image description ...
2
votes
1
answer
58
views
React useState not rendering the current onClick
I have a quandary on the code I'm trying to execute. I'm using controlled inputs and I'm passing the response from an API to a child component, but it is rendering the last value.
Here is my code.
...
1
vote
1
answer
785
views
Setting the results of RTK query with local state in useEffect gives Maximum update depth exceeded warning
I am trying to set the results of RTK query to the local state so that I can change the list based on user actions. See my full code below: but the relevant code is these two statements:
const { data: ...
0
votes
1
answer
73
views
using 2 interdependent hooks
I need to use 2 hooks that depend on each other: useHook1() returns a list of ids and useHook2(id) is called on each of the ids and returns a name.
Basically what I want to do is:
const [allData, ...
1
vote
1
answer
2k
views
Unit testing for mutation RTK Query with fixedCacheKey
I'm currently running RTK Queries for my project and i'm stuck on how to test ComponentTwo.
The below is from the RTK Query doco and is it the exact same scenario I'm in.
For me, in ComponentOne I ...
-1
votes
1
answer
401
views
Getting type mismatch when passing a parameter to Redux Toolkit Query function
I am trying to pass a string to a query in Redux Toolkit (TypeScript)
foo: builder.query<FooResponse, void>({
query: (bar) => ({ // bar gets automatically the type QueryArg ...
0
votes
1
answer
1k
views
When do I use `useDispatch` & `useSelector` hooks with `RTK Query`?
I've started using Redux Toolkit with RTK Query for developing a client-side application that relies on API requests for data. However, I've come across a dilemma. Following the Redux Toolkit ...
1
vote
1
answer
62
views
React redux toolkit useGetFilterProductsQuery and useGetFilterProductsByCategoriesQuery are not defined as functions
I am making a react app using redux toolkit for state management, Here I am getting error message
app_api_apiSlice__WEBPACK_IMPORTED_MODULE_1_.useGetFilterProductsByCategoriesQuery
is not a function
...
0
votes
4
answers
3k
views
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 = ()...
1
vote
1
answer
31
views
Having trouble understanding rtk queries
I'm having trouble understanding how to properly use rtk queries in my code. Initially, they're loading as undefined, which is why I'm adding if statements looking for truthiness, but then this leads ...
0
votes
1
answer
333
views
Passing a state argument set by useEffect to RTK Query's queryFn
I'm passing in a boolean argument, usingAsSignUp, into the queryFn.
Unfortunately, usingAsSignUp always results in undefined! How do I get it's values? usingAsSignUp is state set by useEffect in the ...
0
votes
1
answer
452
views
Use RTK Query inside a hook
I want ta call a RTK Query inside a function to implement some infinite scroll (by fetching new group of data each time it is needed by calling loadMore), so I've tried to use state (myDataState) but ...