Questions tagged [react-thunk]

65 questions
51
votes
3 answers

BrowserRouter vs Router with history.push()

I am trying to understand the difference between BrowserRouter and Router of the react-router-dom (v5) package and what difference it makes for my example below. The documentation says: BrowserRouter A that uses the HTML5 history API…
mitchkman
  • 4,963
  • 7
  • 30
  • 55
15
votes
2 answers

Async initial state React-Redux Redux-Thunk

Using React, Redux, Redux-thunk I want to have an initial state through a server request (API call) but I cannot seem to get this to work. What I have got so far: var Redux = require('redux'); var carReducer = require('./reducers/cars'); var thunk =…
Tikkes
  • 4,219
  • 4
  • 30
  • 57
7
votes
1 answer

react component connected, redux state changes... but no update to component?

I'm creating a React/Redux front-end for a multi-channel chat app. I'm having problems getting some React components to re-render after state change while using redux, react-redux, and redux-thunk. I believe that my reducers are non-mutating, and…
Matthew Moss
  • 1,223
  • 7
  • 16
6
votes
3 answers

Redux - how to call an action and wait until it is resolved

I'm using react native + redux + redux-thunk I do not have much experience with redux and react native I'm calling an action inside my component. this.props.checkClient(cliente); if(this.props.clienteIsValid){ ... } and within that action…
Jobsdev
  • 967
  • 3
  • 9
  • 27
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
  • 1
  • 9
5
votes
3 answers

Redirect to Home after Login on React Redux Application

I am learning React Redux with Create-React-App I am having trouble with the logic of stores, reducers, actions ect. I have a simple login page (some JSX omitted to make it simpler to read) Login.js import React, { Component } from "react"; import {…
michael
  • 6,405
  • 14
  • 52
  • 98
4
votes
2 answers

React Redux - this.props.actions.fetchPosts is not a function

i have issue with calling async action from my component, i think i did everything what was needed to work but seems like not, i used: mapDispatchToProps and inside i return actions: bindActionCreators(fetchPosts, dispatch) and i connect…
Trusislv1
  • 173
  • 1
  • 3
  • 10
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
  • 297
  • 5
  • 17
3
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
  • 667
  • 7
  • 20
3
votes
2 answers

React Native / Redux / Firebase - onAuthStateChanged not dispatched

I'm trying to make a login process with react native / redux / firebase and i got some issues... I try to implement onAuthStateChanged to dispatch an action, but it's not working as i want. It's working for two cases : 1 - I implement directly my…
Bloumdsq
  • 81
  • 2
3
votes
1 answer

React JS asynchronous heavy calculations

I'm trying to do some heavy calculations in JavaScript. I'm currently using React with Redux. Doing a fetch or server requests using some library like fetch or jQuery ajax requests are working asynchronous as expected, however I cannot do asynch…
2
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,081
  • 1
  • 10
  • 25
1
vote
2 answers

Invalid hook call When Call useDispatch in global function?

Code :: import {Alert} from 'react-native'; import action from './../Redux/Actions/auth'; import {useDispatch, useSelector, useStore} from 'react-redux'; import AsyncStorage from '@react-native-async-storage/async-storage'; export const…
Kirit Modi
  • 21,371
  • 13
  • 83
  • 108
1
vote
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
  • 216
  • 4
  • 10
1
vote
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
  • 673
  • 5
  • 15
1
2 3 4 5