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

getState is not a function in React.js

I want to create the package and save it to the database but getting an error that getState is not a function. The redux-store file: const reducer = combineReducers({ adminLogin: adminLoginReducer, packageCreate: packageCreateReducer, }); const…
John Oliver
  • 125
  • 1
  • 11
0
votes
1 answer

How to dispatch second action only when first action is fulfilled ? ReduxTK

I currently have a listenerMiddleware that dispatches login after signup is dispatched. However, I only want to dispatch login IF signup is fulfilled. //Store.js listenerMiddleWare.startListening({ matcher: isAnyOf(signup), effect: async…
benwl
  • 366
  • 2
  • 17
0
votes
0 answers

Redux Toolkit & Formik - Async function not set state

I provide operations with Redux toolkit and formik. I tried createAsyncThunk and normally but the value comes up empty every time. store.ts import { configureStore } from '@reduxjs/toolkit' import auth from './auth' import err from './errors' import…
0
votes
0 answers

createAysncThunk in Redux Toolkit catching error when making fetch request

I'm working on the user registration functionality of an application using Typescript and Redux Toolkit. When I make the fetch request to the signup endpoint, a new user is saved to the database I've connected, but I keep entering the catch error…
0
votes
1 answer

Why am I getting typerror of "RejectwithValue" is not a function

I am trying createAsyncThunk with Typescript. On entering the catch block, I am returning rejectwithValue(param). But on console.log(action) - I am getting error - error: message: "rejectWithValue is not a function" name: "TypeError" …
0
votes
1 answer

React-Native - ERROR TypeError: undefined is not a function (near '...object.map...')

I test from itemList up to the reducer and action, it works fine and it delete the item I want to be deleted but I got this error after that. I wonder what I'm doing wrong here. Can anyone help me what should I do? // ItemList.js import React from…
Almighty Dee
  • 67
  • 1
  • 9
0
votes
0 answers

creating an AsyncThunk that will handle Firebase auth - getting 'stale' auth

I am learning reduxtk and am trying to write an async thunk using createAsyncThunk middleware which will work with firebase auth methods - for example I began with singInWithEmailAndPassword. I know that I can use a regular reducer, let's say in an…
0
votes
0 answers

Redux Toolkit createAsyncThunk, dispatch to certain reducer based on api value

Is it possible to dispatch to only a specific set of reducers based on the return value of your API? I can't seem to find anything about this in the docs. It would go something like below. const myAsyncThunk =…
Brandon-Perry
  • 366
  • 4
  • 18
0
votes
0 answers

I cannot understand WHY I cannot change state in Redux slice

I get the array of objects coming from backend, I get it with socket.io-client. Here we go! //App.js import Tickers from "./Components/TickersBoard"; import { actions as tickerActions } from "./slices/tickersSlice.js"; const socket =…
tresor13
  • 57
  • 8
0
votes
0 answers

Actions must be plain objects. Use custom middleware for async actions. not solving with previous techniques on stackoverflow

Actions File import * as AuthApi from "../api/AuthApi.js" export const logIn=(formData)=>async(dispatch)=>{ dispatch({type:"AUTH_START"}) try { const data=await AuthApi.logIn(formData) …
0
votes
0 answers

Nested lists with redux redux-thunk slices

I'm developing a large App, I chose redux and redux-thunk to manage its state, and now that I have a lot of boilerplates and methods, I feel disorganized. I also smell that some workaround I coded to make some part work, aren't correct. My domain is…
Francesco Bonizzi
  • 5,142
  • 6
  • 49
  • 88
0
votes
0 answers

Redux - initializing a prop in the store with function

Say had a reducer for a certain state ... function thisFunction ( state = new state, action ) { switch(type) { case INIT_STATE: return { ...state, ...action.state } default: return { …
4156
  • 380
  • 4
  • 17
0
votes
1 answer

Redux createAsyncThunk naming convention

one quick question, is it ok to use the same label for my asyncthunk setup ? in my SS it shown as fetchFOrmData - users/fetchFormData since in the doc it always shown as different label
rionalab
  • 42
  • 5
0
votes
1 answer

Passing multiple params from createAsyncThunk to my page

Given the following Slice import { createSlice, createAsyncThunk } from "@reduxjs/toolkit"; import axios from "axios"; const KEY = process.env.REACT_APP_API_KEY const URL = process.env.REACT_APP_BASE_URL const API = `${URL}/interimtoptitles` const…
LOTUSMS
  • 10,317
  • 15
  • 71
  • 140
0
votes
0 answers

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

I'm just learning how to work with redux, and decided to write a user list app. Writing code below, I get an error from the title of this question and I don't know what to do with it at all! I will highly happy if you help me with my…