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

Type 'undefined' is not assignable to type 'WritableDraft | null'

I'm getting the error: Type 'undefined' is not assignable to type 'WritableDraft | null'. in my extraReducer as follows: export const authSlice = createSlice({ name: "auth", initialState, reducers: {}, extraReducers:…
code_learner93
  • 571
  • 5
  • 12
0
votes
1 answer

How to export actions generated from extraReducers and createAsyncThunk

I am trying to write my first async thunk with the provided function from Redux Toolkit: createAsyncThunk. But after hours reading the docs and online instructions, it seems I am missing something as I can't import the action…
A Mehmeto
  • 1,594
  • 3
  • 22
  • 37
0
votes
0 answers

Problems in "Add to Cart" using react redux-toolkit and localstorage

I am adding "add to cart" feature to the eCommerce site using redux-toolkit. I am also using local storage and thunk but it is not working. Products are not added to the cart. Nothing shows on the console. What is wrong with this code? Here is the…
0
votes
1 answer

"add to cart" feature using react redux-toolkit and localstorage not working

I am adding "add to cart" feature to the eCommerce site using redux-toolkit. I am also using local storage and thunk middleware but it is not working. Nothing shows on the console. What is wrong with this code? Redux dev tools Here is the…
0
votes
1 answer

How to handle rejected message with redux/toolkit in a right way

I have an issue about handeling rejected value. If I try to dispath function with a exist email and password everything is working, but when I enter the random email and password I can not reach the 404 error message which is coming from my…
0
votes
0 answers

Redux toolkit how to call action from other slice on one action fullfilled

I have a async action name editLoginIdData() in loginsIdSlice.js, which i am dispatching from certain component, which edits the data in mongoDB database, then when the action is fullfilled, i mutate the state in…
0
votes
1 answer

How can I skip first argument to the payload creator of Redux Thunk using typescript

const fetchUserById = createAsyncThunk< // Return type of the payload creator MyData, // First argument to the payload creator number, { // Optional fields for defining thunkApi field types dispatch: AppDispatch state: State …
0
votes
1 answer

Redux and NextJS 13

I am trying to build NextJs app with 13th version of next and redux. I found the way to pass redux provider in app, but I still don't understand next thing: How can I use "createAsyncThunk" actions or RTK query with "getStaticProps" and another next…
0
votes
0 answers

What is causing the TypeError: middleware is not a function error when using redux-thunk?

I need to use the redux-thunk middleware, but when I pass it as argument to applyMiddleware function it's showing the following error: return middleware(middlewareAPI); ^ TypeError: middleware is not a function This is my code…
Bimal Sunil
  • 23
  • 1
  • 1
  • 4
0
votes
0 answers

Type error when dispatching action with params in redux toolkit

I tried making a user authentication using redux toolkit in Nextjs with Typescript but I keep getting the following error when dispatching an action. Type error: Argument of type 'AsyncThunkAction' is not…
0
votes
0 answers

Argument of type '(dispatch: any) => Promise' is not assignable to parameter of type 'AnyAction'

While dispatching the event I am facing the issue "Argument of type '(dispatch: any) => Promise' is not assignable to parameter of type 'AnyAction'." I am new to React 18 and redux toolkit. Using Redux-thunk, everything seems fine, but dispatching…
0
votes
0 answers

Dispatch action on the slice child component?

const contentType = response.headers.get("content-type"); if (contentType && contentType.indexOf("application/text") !== -1) { response.text().then((result) => { if(result === EC_MSG_CONCURRENTCHANGE){ …
0
votes
1 answer

extraReducers not working when I'm trying to watch for the action on my slice on the same file

I'm trying to trigger the extra reducers, everytime when i dispatch the fillForm action. but the code isn't working. Any help ? export const userSelectSlice = createSlice({ name: "userSelect", initialState: { name: localStoreData?.name ||…
JoyShaheb
  • 129
  • 1
  • 7
0
votes
1 answer

What redux-thunk offer for async call?

I am just getting familiar with redux and redux-thunk. I tried the below snippet to work with the async call, with redux and redux-thunk. const redux = require('redux'); const thunk = require('redux-thunk').default; const axios =…
0
votes
0 answers

next-redux-wrapper wrapper.getServerSlideProps error

On my index.tsx page where i shoud get tracks from server: ` export const getServerSideProps = wrapper.getServerSideProps(async ({store}) => { const dispatch = store.dispatch as NextThunkDispatch await dispatch(await…