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
1 answer

rtk createAsyncThunk doesnt update the state

I am trying to auth session by random user with http get request and createAsyncThunk. fetching the user data in App.js on mount hook. I can see the get request in my network and the new fetched state in redux dev tool, but my TopBar.js useSelector…
Sergey Arenzon
  • 325
  • 4
  • 17
0
votes
1 answer

React Redux toolkit createAsyncThunk doesnt give any return

I am using Redux Toolkit's createAsyncThunk and Axios for async requests. At first, it works, but when I was doing sth with scss, the chrome gives me that TypeError: Cannot read properties of undefined (reading 'map'). I didn't change anything about…
0
votes
1 answer

Redux Async Thunk, API keeps responding with pending

I am creating an app about goal tracker. When I logout from an account, everything goes okay except the the logout gets stuck in pending state. There is also error in console saying Cannot read properties of null (reading 'token') …
Ali Bin Naseer
  • 113
  • 2
  • 8
0
votes
0 answers

Why do I have an error: 'Actions must be plain objects' using redux toolkit?

So I'm using a search bar and redux toolkit to search for a movie that I type, my input looks like this: const [query, setQuery] = useState("");
Carl
  • 345
  • 5
  • 23
0
votes
1 answer

How to make multiple api end point calls in sequential order with react redux javascript?

I have a redux store containing multiple states which is populated by same api but multiple end-points. I have a react app with multiple components, which access to one of these states, and they all call to the correspondent api no mount by…
0
votes
0 answers

Component not rerendering with updated state

Basically, I want to update the comments for a post when the user adds a new comment. However, when the "handleClick" function is called the component is not rerendered with the updated comments and I get the following error: Warning: Can't perform…
0
votes
1 answer

How to use baseQuery outside of createApi in redux-toolkit

In order to reduce my app size, I want to remove axios from my redux-toolkit async thunks. Also, I would like to use my baseQuery function, since it has the global headers of my application. My current async thunk (using axios): export const…
Rashomon
  • 5,962
  • 4
  • 29
  • 67
0
votes
1 answer

redux actions are duplicated when I try to fetch data

I am trying to create load more functionality by fetching only the necessary date i.e. the next one that needs to be added to the existing state that I have in the redux store, but I have a problem my redux actions are duplicated. Component…
Erol
  • 11
  • 1
0
votes
0 answers

Dispatching action in thunk results in error: can't get state of undefined

Here is the action itself: import actionFromAnotherReducer from '../subfolder/reducer' export const asyncAction = createAsyncThunk( 'reducerName/actionName', async( data, { dispatch, getState } ) => { return…
Alopwer
  • 611
  • 8
  • 22
0
votes
1 answer

Can router.push be used from Redux thunk? Is it a good practice?

I have this anchor element:
János
  • 32,867
  • 38
  • 193
  • 353
0
votes
1 answer

Redux Thunk Typescript

I'm trying to make a thunk that filters a base array and passes data into the filtered array, but I keep getting an error when I do a dispatch in useEffect. Writes: "Argument of type '(dispatch: ThunkDispatch, getState:…
Dmitry Staver
  • 139
  • 1
  • 2
  • 8
0
votes
1 answer

How to save response to localStore with Redux Thunk?

They propose to use subscribe for vanilla Redux here: Where to write to localStorage in a Redux app? Here for Redux Toolkit he propose to sort out local storage write operation in a separate thunk, and make dispatch from one reducer to the…
János
  • 32,867
  • 38
  • 193
  • 353
0
votes
1 answer

How To Make A Post Request Using Redux Thunk With Redux Toolkit

I have been using Redux-Toolkit more than the React-Redux. I came across situations where I had to make GET requests, So I recently started using Redux-Thunk (before this I used useEffect but, as it's not a standard way to handle async functions,…
Meet Bhalodiya
  • 630
  • 7
  • 25
0
votes
1 answer

Dispatch action in useEffect's cleanup function

I have a form component in a Material UI which allows users to update their address info. The information is fetched from the API via redux-thunk and the form fields are filled with data from the server before the update has happened. The…
Nima
  • 996
  • 2
  • 9
  • 37
0
votes
2 answers

createAsyncThunk isn't changing state

So, i'am trying to create async thunk action, to mock data from file to the state. import { createAsyncThunk, createSlice, PayloadAction } from '@reduxjs/toolkit'; import mocktasks from './mocktasks'; export interface TasksState { data:…