3,630 questions
-3
votes
0
answers
40
views
Redux state not updating in React component after dispatching action [closed]
I’m building a React project with Redux for state management. I have an action that updates the state, but my component doesn’t reflect the updated state even after dispatching the action.
Code (slice ...
Best practices
0
votes
2
replies
68
views
React RTK Typescript: Using `ReturnType<AppStore['getState']>` vs `ReturnType<typeof store.getState>` when inferring RootState type
I've been reading up on React/Redux documentation, specifically on setting up types for the main redux application store, and was wondering if there are any significant differences when it comes to ...
-2
votes
1
answer
85
views
How to automatically refresh access token when receiving 403 errors in Redux Toolkit async thunks? [duplicate]
I'm building a React application with Redux Toolkit and need to handle token expiration automatically. When my access token expires, the server returns a 403 error, and I want to automatically refresh ...
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
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()
...
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 ...
2
votes
1
answer
114
views
How to disable store persistence between Jest tests?
Has anyone used tests with Jest and run into issues where a Redux store persists between tests? Any ideas on how to reset it or prevent this?
await act(async () => {
render(
<...
0
votes
1
answer
365
views
Module '"redux"' has no exported member 'CombinedState'.ts(2305)
when I upgrade the redux version from 4.2.1 to 5.0.0, shows error:
Module '"redux"' has no exported member 'CombinedState'.ts(2305)
I have read the official release notes: https://github....
0
votes
0
answers
51
views
Redux toolkit synchronization between server store and client store not working
I have set up an apiSlice on the server to fetchProducts in Next.js but the client is not getting the server side store info. There seems to be a lot of conflicting information out there with next-...
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 ...
0
votes
0
answers
150
views
RTK: Is there a difference between using listener middleware on actions vs using extraReducers to respond to actions?
Been getting back into Redux and learning more about RTK. Curious if there is a difference between these 2 approaches to respond to actions
Listener Middleware:
import type { AppStartListening } from '...
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 ...
-1
votes
1
answer
64
views
dispatching two consecutive asyncthunk actions resulting in inconsistent behaviour
I'm building a nextjs app with redux and I'm at the point where I'm dispatching two consecutive asyncThunk actions to the backend api, one action sends a DELETE request and the other sends a POST ...
2
votes
1
answer
91
views
createAsyncThunk and Redux Toolkit update state but State will not Update
I'm trying to use createAsyncThunk from Redux-Toolkit and I'm having trouble and I don't know how to solve it.
I called createAsyncThunk from another component, and this createAsyncThunk changed the ...