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
3 answers

Data is not always coming from the API

I need your help. I am using react and redux along with typescript in my app. Using the code below, I get my products and their categories. The fact is that I get my products and they look great, but the categories don't work very well: sometimes i…
0
votes
0 answers

how can i use redux flutter thunk action in a future builder

FutureBuilder( future: store.dispatch(fetchHomeAction()), // a previously-obtained Future or null builder: (BuildContext context, AsyncSnapshot snapshot) { List children; if (snapshot.hasData) { …
0
votes
0 answers

React "Render process gone" and "TypeError: Failed to fetch"

Description of behaviour I have a React application which has a component where the user can upload multiple CSV files. The following happens on the client side: Redux dispatch is used to trigger an async thunk action. Inside that action: An…
0
votes
1 answer

How can I call a asyncThunk action of redux-toolkit inside a getServerSideProps of nextJs 13

I am using nextJs 13 and redux-toolkit and i am fetching my data with AsyncThunk . Now, I want to get my data with getServerSideProps inside my UI component at the first render. I tried to use the next wrapper, but the action is not being called at…
Peach
  • 29
  • 4
0
votes
1 answer

Argument of type '(dispatch: Dispatch) => Promise' is not assignable to parameter of type 'AnyAction'.ts(2345)

guys. I started to create async actions with redux and got an error, when I put async action into dispatch: Argument of type '(dispatch: Dispatch) => Promise' is not assignable to parameter of type 'AnyAction'.ts(2345) async action: import {…
stephaniex
  • 35
  • 6
0
votes
0 answers

After dispatch first async thunk function how to dispatch another one with out any event in node application

// Create async thunk to get random video const fetchVideo = createAsyncThunk('video/fetchVideo', async () => { const response = await fetch('http://localhost:9000/video'); const video = await response.json(); return video; }); //…
Wyarej Ali
  • 11
  • 2
0
votes
0 answers

Error on installing redux-thunk (npm install redux-thunk)

I got multiple errors while installing redux-thunk. here's the error message: npm ERR! code ETIMEDOUT npm ERR! syscall connect npm ERR! errno ETIMEDOUT npm ERR! network request to https://registry.npmjs.org/redux-thunk failed, reason: connect…
0
votes
1 answer

Redux doesn't save state even reaching type [Solved]

Update:I think I found my problem I somehow access my state by useSelector(state => state.auth) which didn't save my ordersReducer. please help me. I have this code that I already reached SAVE_ORDERS_SUCCESS but it doesn't save the state of it. Here…
Long.TH
  • 21
  • 3
0
votes
1 answer

cannot destructure property 'getstate' of '_ref' as it is undefined (asyncThunk)

export const addTeamReview = createAsyncThunk( "team/addTeamReview", async (teamId, comment, { getState }) => { const { userLogin: { userInfo }, } = getState(); try { await axios.post(`/api/teams/${teamId}/review`,…
Shifin
  • 1
  • 1
0
votes
1 answer

Why am I getting a 301 and CORS response from Django Rest Framework while the request works well in Postman?

I am trying to make an API GET request from a React & Redux app to a Django app, but am getting an error about CORS with a 301 response. Below is the response Here is the React & Redux code: const fetchClasses = createAsyncThunk( GET_CLASSES, …
0
votes
1 answer

Use Redux Thunk and RTKQuery together

I am working on big admin dashboard project, with lots of API calls and state managements, Our theme is ready and we are using next.js 13 instead of just react for better development and easy routing control (also SSR and other features...), for…
Cypher or KJ
  • 51
  • 2
  • 16
0
votes
1 answer

Redux createAsyncThunkFromAPI wrapper issue

https://stackblitz.com/edit/react-ts-rkekhf?file=app/redux/asyncThunkFromFetch.ts We use the following helper to create thunks: import { createAsyncThunk } from '@reduxjs/toolkit'; import axios, { AxiosPromise, AxiosResponse } from 'axios'; import {…
yevt
  • 732
  • 1
  • 6
  • 21
0
votes
1 answer

Is it okay to use the same reducer to update one of two state properties depending on other state value?

So let's say hypothetically, I have one reducer where I want to either update state.propertyA OR state.propertyB depending on the value of state.propertyC. something like: const conditionalReducer: CaseReducer = (state,…
0
votes
0 answers

How to retrieve object after post in react redux from api

I created a Todo application in React.js. I have an API to store my todos and their states. In my application I can drag and drop the todos in the state I want and I can also CRUD the states. For the state part I use React-Redux. My problem happens…
0
votes
1 answer

How to type CreateAsyncThunk response data for proper storage and handling of state?

When writing a project, the Calculator encountered such a problem. I was given the task of dividing the project into modules, which, if necessary, can be replaced by others. Let's take the API as an example. The API code should be written in such a…
tresor13
  • 57
  • 8