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

Ignoring subsequent Redux Thunk dispatches

Imagine this action: export const myAction = createAsyncThunk(...) I dispatch the action in 2 different React components, both of which need this action to populate the state they depend on: useEffect(() => { dispatch(myAction()) },…
Molten Ice
  • 2,715
  • 1
  • 27
  • 37
0
votes
1 answer

How to implement remember me functionality in react js

I'm making a simple login signup form with remember me functionality in react js along with redux, thunk and redux-persist. When I send correct login details i.e. email and password the api returns a non changing (permanent) access_token. Expected…
0
votes
0 answers

React router dom will not re render page but URL is changing on click

My components are not rendering on "Link" clicks but the url route does change, and if I manually refresh the browser the correct page renders. I have a private route created for the '/' path that uses a redirect if the user is not authenticated and…
0
votes
1 answer

Is there a way of running an if statement on whether or not props have changed in React

I currently have a component that holds a posts array, this component takes in a prop called sortBy which tells the component to either fetch data sorted by popular or new. The way my component is set up is upon initialization the posts are fetched…
Dylan L.
  • 1,243
  • 2
  • 16
  • 35
0
votes
1 answer

DRY redux actions

I wonder what is the best approach to dry out common redux actions ('m using redux-thunk) for example I have these two components: const Main = ({list, onLike }) => (
    {list.map(item => (
Federico
  • 5,438
  • 5
  • 39
  • 47
0
votes
1 answer

How to apply builder notation with redux thunk?

I try to use builder notation: https://redux-toolkit.js.org/api/createSlice#the-extrareducers-builder-callback-notation but got this error: Expression expected. here, in last line in extraReducers: }, import { createSlice, createAsyncThunk,…
János
  • 32,867
  • 38
  • 193
  • 353
0
votes
1 answer

React Thunk Resolver reasie error: A computed property name must be of type 'string', 'number', 'symbol', or 'any'

Got this error: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. In this line > [getAuthnUser.fulfilled](state, { payload }) { Component: import { createSlice, createAsyncThunk, PayloadAction } from…
János
  • 32,867
  • 38
  • 193
  • 353
0
votes
1 answer

React Prevent re-fetching on page changing

i'm currently working on a react app that fetches some content from my backend, which results to be very heavy. My intention is to keep the component alive and prevent re-render every time the user changes from one page to another. Currently i'm…
yieniggu
  • 384
  • 1
  • 7
  • 20
0
votes
1 answer

React Redux update api with createAsyncThunk

I'm trying to update api with React Redux using createAsyncThunk, Status Code is 200, but data is not updated. Api are developed with Laravel Passport and working fine using Postman. export const fetchUpdateLead = createAsyncThunk( …
cloude
  • 338
  • 5
  • 18
0
votes
0 answers

Updating form values on redux store on each change

i'm currently trying to store some form input values on store each time they are changed. However on each new dispatch the string only takes into account the last-1 char. Let's say i write Hello! on my input. In store it will save just Hello This is…
yieniggu
  • 384
  • 1
  • 7
  • 20
0
votes
1 answer

how to use redux thunk to fetch data

guys hope you all are doing great, Well I am using redux and I am not getting my result, I would like to describe my issue step by step I hope it will bater for understanding (1) POSTMAN RESULT (i) get request , (ii) JSON data Here is the code of…
Zaryab Khan
  • 73
  • 1
  • 13
0
votes
1 answer

How i can use thunk inside another thunk in Redux?

I created thunk by redux toolkit "createAsyncThunk" and i do some async operations here export let Login: any = createAsyncThunk("authPage/Login", async ({values, action}: any, {dispatch, rejectWithValue}) => { try { let…
Yefimchuk
  • 67
  • 2
  • 6
0
votes
1 answer

useEffect/useCallback missing dependency warnings, but redux state does not let me fix it

I'm trying to clean up my warnings, but im facing those dependency warnings. This is an example, but a lot of useEffect() is facing a similar problem. Im trying to laod my page calling my fetch api inside useCallback (got samething inside…
RenanY.
  • 1
  • 1
0
votes
2 answers

Where is a best place to make API call using React, Redux-thunk?

I've already checked StackOverflow.com and also the entire internet for a similar question and didn't find any, so please ignore and do not give a negative reputation if you find one as I need reputation in this moment of my life! My code works fine…
Khaled Rakhisi
  • 317
  • 1
  • 4
  • 18
0
votes
1 answer

React useSelector and getState returning different values in useEffect

I've been following the official Redux tutorial to create and dispatch asynchronous thunks (created with createAsyncThunk) to load some user state. I have two components, say A and B, and they both need access to the same userState information. I'm…