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

How do I map an array of objects to different objects (with different properties) in a Redux Slice?

Trying to asynchronously filter and transform an array of objects that I receive from my backend. I'm using Redux with React to manage store. Here's what I have now in my slice.js: ... export const getData = createAsyncThunk('foo/bar', async…
0
votes
1 answer

How to update my redux store synchronously?

I have a function that is being dispatched twice in small time duration. Suppose 1st call was made on time X and second call was made on time Y. Where Y > X and difference between X and Y is 5 millisecond or less. Call made at time Y is updating the…
Hari
  • 88
  • 1
  • 1
  • 10
0
votes
0 answers

inserting header axios async thunk

I'm trying to set apikey in the header of req-- it gives me Cors error when done locally, though when done on postman it goes through export const fetchCreativeAd = createAsyncThunk( 'creativeAd/fetchCreativeAd', async (payload, thunkAPI) => { …
user17999103
0
votes
0 answers

How to pass argument when using createAsyncThunk?

Checked this, but pass one argument and destructing did not help. How do you pass arguments to createAsyncThunk in redux toolkit? Have this: export const login = createAsyncThunk("users/login", async (user, params) => { const { name, data } =…
János
  • 32,867
  • 38
  • 193
  • 353
0
votes
1 answer

TypeError: dispatch is not a function when clicking the toggle button

I am using react redux-thunk. I have a set of users data that I get from an API and this is the schema: . I've connected the "active" property with the checked attribute of a Switch MUI button, so naturally when calling the API I have some users…
Zoi K.
  • 361
  • 2
  • 3
  • 11
0
votes
1 answer

How to Get createAsyncThunk In The Correct Way Data React Native

I am a new in react native Redux Newest Documentation. I want to use createAsyncThunk to get my api data using Axios. Below my code : App.js import React, { useState } from 'react'; import { Provider } from 'react-redux'; import { configureStore }…
Dennis Liu
  • 2,268
  • 3
  • 21
  • 43
0
votes
1 answer

Return Promise { "_U": 0, "_V": 0, "_W": null, "_X": null, } in REDUX Reducer React Native

This is my code in using REDUX : ApiChartingReducer.js const ApiChartingMenuInitial = { apiData: [] }; export const ApiChartingMenuReducer = (state = ApiChartingMenuInitial, action) => { switch (action.type) { …
Dennis Liu
  • 2,268
  • 3
  • 21
  • 43
0
votes
1 answer

Try to connect Action with Reducer but get Error: Uncaught (in promise) TypeError: dispatch is not a function

Friends, I have a problem with the connection between Action and Reducer when trying to send data that come back from the API I get dispatch, not a function and when trying to console.log(action.type) I get @@redux/INITw.y.u.w.s.a are any help, and…
Ahmed Radi
  • 677
  • 1
  • 5
  • 20
0
votes
0 answers

Mapping over id array and making api requests returning not what im expecting

I'm trying to dispatch a redux action with an array of id which i'm sending to a get request which takes the id and returns a new json for each time item of id im sending, the array im sending has 10 ID and i want to make 10 requests for each id (…
Mentor_Aliu
  • 11
  • 1
  • 4
0
votes
1 answer

React: React-Redux: Redux-Thunk: Memory Leak on Unmounted Component

Im going to formulate this question as best I can because this is very confusing. I am using redux for my applications state. and I am using redux-thunk to handle all of my async api calls to the database. I am using redux-thunk to handle my async…
Gabriel Coach
  • 23
  • 1
  • 4
0
votes
1 answer

export 'actionTypes' (imported as 'actionTypes') was not found in './pages.actionTypes'

I am building a React app that uses Redux-Thunks. I am receiving an error message and cannot figure out how to resolve it. I am new to using Redux-Thunks and have been using this tutorial to set up . I checked all my dependencies and files to ensure…
user3574939
  • 819
  • 3
  • 17
  • 34
0
votes
1 answer

redux state is undefined in useEffect and useSelector

I am new to redux. Currently I am working on a project that shows nearby bike stations on map by API call. So that means most of the redux actions are async and returns some data for next api call in another action. When I dispatch all my actions in…
Saidamir
  • 134
  • 2
  • 12
0
votes
2 answers

Clarifying advice on strategizing use of Redux-saga, Redux-thunks, Context-Hooks, and/or React-query - with React project (Next possibly)

I've been attempting to understand the relationship in using these in projects. Determining which is appropriate/advantages is making me go a little crazy and I don't want to assume that something is correct out of frustration - so I must submit and…
ASG4
  • 169
  • 2
  • 9
0
votes
1 answer

Dispatch type for custom middleware in redux

I'm using redux toolkit, and have created a thunk using createAsyncThunk that gets called from a middleware (code below). What is the correct dispatch type? Right now it only works if I specify "any". import { Action, Dispatch } from…
0
votes
1 answer

Can I return value from action creator using redux-thunk?

I've seen a lot of examples of async action creators, but they all do some sort of fetching and pushing data to redux store and return nothing. I need another logic that looks something like: const createUserAction = (user) => { …
Oleg
  • 49
  • 1
  • 6