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

what is the difference between keepUnusedDataFor and refetchOnMountOrArgsChange?

I am working with RTK query and I have a project that I am working on, where I want to make an API call every 5 seconds (interval), and I do not know the difference between the keepUnusedDataFor and refetchOnMountOrArgsChange property. Which one…
neil
  • 353
  • 1
  • 8
  • 17
0
votes
1 answer

How to trigger a delayed function call after you have navigated away from the page in React

So I have a really ask but the implementation is eluding me. I want to simulate the completion of a task in the background in our product demo. The User Journey : Arrive at the home page Click button on the home page -> Button goes into loading…
0
votes
1 answer

Why post call made using fetch in my react app fails when the same is successfully executed in postman?

I am making a post API call using fetch in my react app (redux-thunk) and getting a '401-Unauthorized' error. but, I made the same post request in postman with the same Authorization token and it returned a successful response. While trying multiple…
Dhinesh
  • 141
  • 1
  • 4
  • 18
0
votes
1 answer

Is it possible use Redux Thunk without Redux?

Got this error: useStore.js:20 Uncaught TypeError: Cannot read properties of null (reading 'store') In our architecture we have a 1. React / Next.js app and a 2. React based WordPress plugin. In the Next.js app we uses the classis Redux thunk…
János
  • 32,867
  • 38
  • 193
  • 353
0
votes
1 answer

Thunk chaining within a thunk (using Redux toolkit). How to call a thunk when another one finished?

My application allows users to enter data in many different places, and each time I use something like this to call an async thunk: dispatch(handleDataEntry({ key, value }) In some cases the results of the API call inform the application that…
ed94133
  • 1,477
  • 2
  • 19
  • 40
0
votes
1 answer

Uncaught (in promise) Error: When called with an action of type

Not sure what I am missing... The request is okay and I can see the data when I console.log in the action creator but for some reason the reducer does not work properly. Here is the code: Action: import jsonPlaceholder from…
0
votes
1 answer

Implementing redux-toolkit error with async function types and usage

I'm trying to implement react redux toolkit into my application. Everything went fine, but I will need a async function. I was following the basic docs to implement it but I don't know the cause of this issue. The first issue is regarding to…
0
votes
1 answer

How resolve rejected promise in redux using createAsyncThunk with nextJs?

I am trying to create a player, using a POST request but getting the error as promise rejected in redux devtool. But I can see the data on the UI. I am using createAsyncThunk and createEntityAdapter: createAsyncThunk export const addPlayer =…
Tapesh Patel
  • 131
  • 1
  • 17
0
votes
1 answer

why my reducer won't update the state ? -Redux

i'm trying to remove an item from array with filter method. i see ItemRemoved in Redux Dev Tools but nothing happen in state. Why is this happening? i will really appreciate some help. this is driving me crazy import { createSlice, createAction }…
Solid1
  • 426
  • 1
  • 2
  • 14
0
votes
1 answer

Why filter method in my reducer returns an array of proxy? -Redux Toolkit

so i want to delete an item from array, onClick but when i log the filtered data in the console i get an array of Proxy. i tried Changing my code but nothing worked whats wrong here in itemRemoved? import { createSlice, createAction } from…
PPs
  • 21
  • 5
0
votes
1 answer

How to pass data from useSelector (redux) to useSate hook in react?

Hi i am trying to work on a app, which has some predefined code of redux, and react. I am trying to get the players data which is formated json file and pass it to useSate hook. The data which I get using const players = useSelector(getPlayers); //…
Tapesh Patel
  • 131
  • 1
  • 17
0
votes
0 answers

useSelector getting state multiple times

I'm using react, redux, and redux toolkit (redux-thunk). so I'm trying to get lists from the server and show it on the page. i used dispatch and saved the response in redux and used useSelector to get lists in the response. everything is working…
nugget
  • 1
  • 1
0
votes
1 answer

React/Redux updating and accessing state value

How can I update a local state and then access the updated value within the same function scope? I am trying to update the store in redux, I am taking values from a local state, I'm doing this from inside the same functional scope that the state is…
HotSauceCoconuts
  • 301
  • 5
  • 19
0
votes
0 answers

Redux saga Method is being called twice(React Native)

Redux saga method is being called twice in React native application. Please find saga.ts export function* fetchValueLable(action: IFluxStandardAction) { try { if (!action.payload) { return; } const response = yield…
Kartiikeya
  • 2,358
  • 7
  • 33
  • 68
0
votes
1 answer

useSelector is not giving the value after useDispatch

I have an api which gives me the result, and I can see the data in my console, but I'm not able to get it in useSelector. import { createAsyncThunk, createSlice } from "@reduxjs/toolkit"; import axios from "axios"; import { useNavigate } from…
Venky
  • 1,929
  • 3
  • 21
  • 36