Skip to content
Advertisement

Dispatch() calls a function but .then() doesn’t work on React-Redux

I’m creating my first React-Redux App. I’m using yo generator-redux and following this repo and official documenation. I have rendered de SignIn Presentational Component and it works fine, show errors if inputs are blanks. The problem is at dispatching. I use Thunk Middleware but the repo doesn’t.

I have used console.log() to explore how deeper is working my code and I found that the Component Actions are being called, the AJAX request (with axios) is working fine, but the .then() (I think) is not working but doesn’t throw errors.

This is my code:

Action

actions/UsersActions.js

JavaScript

Component

components/SignInForm.js

JavaScript

Container

containers/SignInFormContainer.js

JavaScript

Presentational/Page/View

presentational/SignIn.js

JavaScript

Reducers

reducres/UserReducer.js

JavaScript

reducers/index.js

JavaScript

Store

JavaScript

index.js

JavaScript

I hope you can help me! I don’t know if something is wrong because I’m using Thunk and the example don’t, or if something is missging.

Thank you guys!

Advertisement

Answer

I solved my issue. The difference is that I need to process de Promise received from signInUser throug the attribute that has it.

I had to receive the response in response and then access to the Promise in response.payload. In addition, I had to use .then() and .catch() to handle it.

JavaScript
Advertisement