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

Awaiting dispatch actions to end

is it possible to await for dispatch action to end, so then, with that dispatched data before, I could use it in another function? Currently I have this type of code, but I believe I shouldn't pass request to action and I should use const url =…
funnyguy
  • 107
  • 1
  • 6
0
votes
1 answer

ReduxToolKit | CreateEntityAdaptor userSelectors.selectAll giving Cannot read properties of undefined (reading 'map')

Hi i am using ReduxToolKit CreateEntityAdaptor for crud, when i get all users from API by using userSelectors.selectAll, it gives "Cannot read properties of undefined (reading 'map')". let me show my API response. { "data": [ { …
0
votes
0 answers

Redux. How to change params in middleware

I have problem, I need to change params in the same request, comments are in the bottom of the code const myMiddleware: Middleware = (store) => (next) => (action) => { if (typeof action === 'function') { action(store.dispatch,…
0
votes
0 answers

react js and redux-thunk: When I add Dispatch into Dispatch, Infinite loop happens to me

I have a problem, I'm looking for a solution, please help. I am building a React application and using Redux thunk to call the data from the backend This is the code inside the useEffect let [events, setEvents] = useState([]); let [featured,…
o M a R
  • 11
  • 2
0
votes
1 answer

Why? Module parse failed: Duplicate export '_actions'

I do not see any duplicated export. Do you? // slice.ts import { createAsyncThunk, createSelector, createSlice, current, PayloadAction, } from '@reduxjs/toolkit' import axios from 'axios' import { DataBundlesInitial } from…
János
  • 32,867
  • 38
  • 193
  • 353
0
votes
1 answer

Mock redux thunk API call

I'm just trying to make a mock response in my thunk handler, but I can't spot the place I did wrong. I have added some comments in the redux controller to get a clear view. can someone help me to get what I want? component const handleRequest = ()…
SFernando
  • 1,074
  • 10
  • 35
0
votes
1 answer

Prevent custom hook from running twice

I am fetching data from the api using a createAsyncThunk action function. I created a custom hook to call this dispath function everytime: export default function useFetchTransactionHistory() { const dispatch = useDispatch(); …
Keenlabi
  • 163
  • 1
  • 2
  • 11
0
votes
0 answers

redux store push payload add to cart not working

I'm having a hard time to debug this cause I'm not sure if my approach is correct.. once I do some request the my action call returns me undefined action and simply not pushing my object on my redux store. // here's my store const initialState = { …
Gino
  • 77
  • 7
0
votes
0 answers

React redux update item in array works async

There is a section in my application where menu settings can be made.With these settings, users will be able to see the screens they want. I keep these settings in a redux array and update them with switches and store them in async storage. But…
ttars
  • 69
  • 6
0
votes
0 answers

redux reducer payload.data not reflecting on front end

I'm having trouble of my payload.data getting sent on my reducer It won't reflect on my front-end/UI after I made a request unless I refresh the whole page...can someone tell me where I went wrong with my approach since I'm a newbie in redux. //…
Gino
  • 77
  • 7
0
votes
1 answer

Redux thunk fetch returns function instead of value

Hello everyone I'm a beginner currently learning programming, I'm trying to make a webapp that fetches posts from reddit and displays them in a website, I have created an async thunk to fetch the data from a reddit API, when I log it to the console…
0
votes
0 answers

Batching API requests with React Redux thunks after page render

I have a React app for fetching and displaying hundreds of posts. The API I'm working with supports fetching multiple posts in a single request (https://my.api/posts/1,2,3 would return posts with ids 1, 2 and 3), and I want to make use of this…
0
votes
0 answers

Hydrate Nextjs React Redux Thunk

Problem: Error: Hydration failed because the initial UI does not match what was rendered on the server. How can I iterate the cart without having to create another state :c const initialState = { cart: Cookies.get("cart") ?…
0
votes
2 answers

Cant use localStorage in nextJS

I'm developing a cart system and the problem is that, when I add a product to the cart, it works in context and localStorage; but, when I refresh, the data is gone. const dispatch = useDispatch(); const { cartItems } = useSelector((state) =>…
Yun
  • 7
  • 4
0
votes
0 answers

Cant use Redux thunk show list products

Cant use Redux thunk show list products Cant use Redux thunk show list products Cant use Redux thunk show list products Cant use Redux thunk show list products Cant use Redux thunk show list products Cant use Redux thunk show list products Cant use…
Yun
  • 7
  • 4