Starchand
Starchand

Reputation: 714

Redux with react-navigation (reactnavigation.org)

I'm working on an example project integrating https://reactnavigation.org/ with Redux.

I have all the navigation stuff working and have set up an action inside my dashboard to get data from an API on fetch button click. https://github.com/starchand/SampleNavigation/blob/master/app/containers/dashboard/views/Dashboard.js

This is working - I am getting the data, however I am also getting an random action being executed before:

enter image description here

Any ideas whats causing the first action?

Full repo: https://github.com/starchand/SampleNavigation

Upvotes: 1

Views: 673

Answers (1)

rgommezz
rgommezz

Reputation: 13916

Just by taking a quick look at your code, it seems to me the order of middleware you are applying to the store should be the reversed.

When you are doing this.props.fetchQuestions(1); inside your Dashboard component, you are dispatching a function (or thunk) instead of a plain object. Since redux-logger is the first middleware in the chain, it's logging the function itself, with obviously undefined action type. Reverting the order of middlewares should fix the problem.

Inside https://github.com/starchand/SampleNavigation/blob/master/app/store.js#L16 try:

 return applyMiddleware(thunkMiddleware, logger())

Upvotes: 2

Related Questions