Questions tagged [react-thunk]
48 questions
6
votes
2 answers
Why do I need redux async thunks
I'm new to whole react redux world but I would like to think that I now know how redux works. However right now I'm facing a new challange I need to implement async data fetching. I've choose to use axios as my http client.
The problem I have right…

Teamol
- 733
- 1
- 14
- 42
5
votes
0 answers
JHipster and React: How to call function after calling asynchronous reducer action?
Use Case: I have a react application generated with JHipster. I need to get data from API, map to form contract, and then submit the form.
Problem: JHipster generated reducer code doesn't return a promise, so how do I know when a reducer action is…

user2370642
- 119
- 2
- 9
3
votes
0 answers
Correct way of redirecting after successful async action: Passing "history" to thunk as argument VS using conditionally with Redux store?
I've learned of 2 methods to redirect to a different page after executing an async action with Redux Thunk:
1-Method: Passing "history" object to the async action as argument.
In your component you define the "history" object with "useHistory" hook…

Alvaro Bataller
- 487
- 8
- 29
3
votes
0 answers
Axios catch will not trigger
I have a react app that the user will enter info into a redux form and the function is called. I have a axios post that will not catch an error. I'm not sure what this is happening.
export function vehicleformsubmit(props){
const input={
…

Roro
- 427
- 2
- 8
- 20
3
votes
3 answers
Can Redux manage just a boolean?
I have a piece of state in my React & Redux App dealing with authentication. It's a boolean.
I'd like to simplify grabbing this piece of state from the Redux store but can't find examples of this.
Is this approach a bad idea? I know that mutating…

PrimeTimeTran
- 1,807
- 2
- 17
- 29
2
votes
1 answer
How to prevent batching with React-Redux
I am trying to explain the React-Redux batch() function on my website. In order to do so, I need a counterexample without using batch() so that the reader can see the difference. However, as you can see here on CodeSandbox, I couldn't get the…

Chong Lip Phang
- 8,755
- 5
- 65
- 100
2
votes
1 answer
useEffect is causing an infinite Loop
I am getting an infinite loop and it is constantly fetching information from the API.
The issue can be solved if I wrap fetchTheMovie() inside an if statement but I do not understand the reason, any ideas or any better solution?
if (!movie.Title) {
…

IonKat
- 436
- 6
- 12
2
votes
0 answers
(React-Native) Manifest is not a valid JSONObject or JSONArray
I am using expo for react-native development i want to use redux and redux-thunk in my react native application for that i create project using command expo init myproject and after that
cd myproject.
Now when i run expo start command it build…

king saqib
- 33
- 2
2
votes
1 answer
multiple api call actions in the redux thunk
I am using redux-thunk . Here, I have one login action. On that action I am calling an API which will give me some token, that I have to store in the state. Then immediately, after success of this action, I have to make another API request which…

ganesh kaspate
- 1
- 9
- 41
- 88
2
votes
1 answer
Uncaught TypeError: dispatch(...).then is not a function
Container component
import { connect } from 'react-redux';
import { signUpUser } from '../actions/userActions';
import Register from '../components/register';
function mapStateToProps(state) {
return {
user: state.user
};
}
const…

Pravin Pawar
- 2,559
- 3
- 34
- 40
1
vote
1 answer
How to get data from store before render in React-redux?
I need to render component by route "courses/:courseId", but I got an error "Uncaught TypeError: Cannot read properties of undefined". It's because courses is empty just after render.
import React, { useEffect, useState } from 'react';
import {…

Vitalii Bilostotskyi
- 13
- 2
1
vote
1 answer
Redux thunk middleware does not give the required output
I am new to Redux and am learning redux from here.
I followed through till video 13 and all the examples worked fine.
However, I am unable to get the desired (or any output) for the code shown in video number 13
File: asyncActions.js
Code:
const…

kesarling He-Him
- 1,944
- 3
- 14
- 39
1
vote
1 answer
How to use createThunkAsync without createSlice
I have a simple reducer. Which I use in combineReducers and then in createStore. I would like to work with async thunks a little bit to fetch data using axios. What I don't see nowhere is how to use thunk without createSlice functions. Can you point…

Teamol
- 733
- 1
- 14
- 42
1
vote
1 answer
In presentational component, Redux Store state is undefined
I want to access Redux Store State in presentational component, but the state is undefined.
I made Container Component, Presentational Component, and Redux Store.
So I tried to access user in presentational component but user is undefined.
I use…

Lia
- 13
- 3
1
vote
0 answers
How to unsubscribe a firestore snapshot listener when component will unmount?
I am using React with Typescript and redux with the thunk layer. So, I defined one of my action as follows and it deals with a firestore snapshot listener.
export const getEmployees = () : ThunkAction => {
…

Amesh Jayaweera
- 216
- 2
- 11