Questions tagged [redux-thunk]

Thunk middleware for Redux. Redux Thunk middleware allows you to write action creators that return a function instead of an action. The thunk can be used to delay the dispatch of an action, or to dispatch only if a certain condition is met. The inner function receives the store methods dispatch and getState() as parameters.

Redux Thunk middleware allows you to write action creators that return a function instead of an action. The thunk can be used to delay the dispatch of an action, or to dispatch only if a certain condition is met. The inner function receives the store methods dispatch and getState() as parameters.


Related tags

2622 questions
0
votes
2 answers

How do I output the data received through Redux Thunk?

I'm currently mastering redux and haven't really figured out how to output the data you get from the server using thunk. I in useEffect do a thunk dispatch, get server data, but they don't output because they come after a couple of seconds, so in…
Dmitry Staver
  • 139
  • 1
  • 2
  • 8
0
votes
1 answer

Is it possible to use an external axios handler with createAsyncThunk

I have a API handler with different functions using Axios for get, post, patch, etc. I want to use those API handler with createAsyncThunk from redux toolkit, is this possible? it would be something like export const paymentMethods =…
0
votes
1 answer

Redux - updating store based on async api calls

I have a use case to render page using redux with graphql api calls. On first component will call default action to fetch data from graphql, and stores in redux state as below state = { films: { totalCount: 6, films: [ …
0
votes
1 answer

CreateAsyncThunk Problem with 400 Bad request

i have created a asyncthunk, but when status code is 400, the result of request is still fulfilled, which method is to handle a 400 error with createasyncthunk and fetch api? This is a action code: import { createSlice, createAsyncThunk } from…
0
votes
1 answer

Redux-Thunk Error : store.dispatch(...).then is not a function

import ReactDOM from "react-dom/client"; import { Provider } from "react-redux"; import reportWebVitals from "./reportWebVitals"; import AppRouter from "./routers/AppRouter"; import "./App.css"; import configureStore from…
0
votes
1 answer

How to pass parameter from thunk to extraReducers?

I know extraReducers can receive payload data, but can it receive patameter directly from thunk method? Normally I have this in extraReducers: .addCase(loginEmail.fulfilled, (state, { payload }) => { state.authnRes = payload }) But I would get…
János
  • 32,867
  • 38
  • 193
  • 353
0
votes
0 answers

Why do we need to dispatch the call to the action creator and dispatch within the action creator itself?

I'm learning about redux-thunk and don't quite understand the logic here. I'd appreciate if someone could explain the flow. The tutorial I'm following does this: //App.js useEffect(() => { dispatch(getPosts()); },…
0
votes
1 answer

Trying to pass action.payload from one slice to another different slice

What I am trying to achieve is sending action payload from one slice to another and I have been stuck several hours trying to do so. I have tried accessing the global store but the problem is I am getting errors on doing so I am using redux-tool-kit…
0
votes
2 answers

How to call generator functions with React-Thunk

I'm in the process of converting some sagas to thunks. Some of these sagas have nested generator functions that I'm not able to call within thunks. Normally in a saga I do: const result = yield call(myFunction, anotherSaga, params); However when i…
ertemishakk
  • 517
  • 3
  • 14
0
votes
1 answer

react-native redux-toolkit: a non-serializable value was detected in the state, but my object is serializable

I just migrated my old-school react-native with redux App to the modern redux-toolkit and now I have this error: A non-serializable value was detected in the state, in the path: `currentUserSessionData.data`. Value:, CurrentUserSessionData { …
Francesco Bonizzi
  • 5,142
  • 6
  • 49
  • 88
0
votes
1 answer

TypeError: Cannot perform 'get' on a proxy that has been revoked, redux-toolkit and nextJS

I'm get the error in tittle when a action is dispatched to redux in a next application and i can't find the solution: the first action is correctly dispatched but others raises the error: TypeError: Cannot perform 'get' on a proxy that has been…
0
votes
0 answers

Redux thunk returns value before fetching data

I'm trying to fetch data from firebase Realtime Database and put it into the store. Fetching data from Firebase has no problem. It works fine. The problem is that the thunk is fulfilled even before data being fetched. I first tried the code below…
0
votes
1 answer

Undefined redux values in console

I am trying to check if the user is logged in or not in Register.js component but I am getting undefined values of auth state in it. Please look into it if you can find where I am doing wrong. I have tried doing a lot of changes still I was not able…
saurav raj
  • 41
  • 6
0
votes
1 answer

How to export Redux state field?

Got this error: Property 'authnUser' does not exist on type 'TypedUseSelectorHook'. I try export like this: export const authnUser = (state: TypedUseSelectorHook) => state.authnUser I have following…
János
  • 32,867
  • 38
  • 193
  • 353
0
votes
1 answer

Uncaught ReferenceError: Cannot access createAsyncThunk before initialization within a redux toolkit slice

I'm currently struggling to solve this error which i believe might be a circular reference dependency issue within my react redux application. It was working fine at first but then all of a sudden my app is throwing this error: From the error, it…