-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Navigating when changing redux state #2374
Comments
Duplicate of #2115 |
Thank you for your reply. I already read #2115 and didn't understand the fact that i need to call ACTION.... in the reducer? for now it's working but is it the correct way to do it?
|
It is possible but it is not fully 'redux' style. So with v4 you could do the same as with react-navigation - integrate your reducer with navigation reducer and pass own dispatch/state into RNRF. |
You should refer to mentioned demo. |
@aksonov I tried to implement from this demo link but i was getting an error in the getStateForAction. I guess because it was returning in the reducer |
@geniuscd , yeah I got the same. Did you get around the error? |
@ssomnoremac yes :P i used react-navigation |
I also got the error and fixed it. // it is important to load reducers AFTER actions.create (so no import here)
const reducers = require('./reducers').default; You should make sure your implementation import the reducer by correct order. When I changed the above line of code to the correct place, and it worked. |
@jordenchang55 that got me around the error, thanks. My
|
@ssomnoremac I compared our code, and found that changing your store resolves the problem. // Your code
const store = compose(applyMiddleware(...middlewares))(createStore)(reducers);
// My code
const store = createStore(
reducers,
compose(
applyMiddleware(...middlewares)
)
); |
hmm, strange, that didn't fix it for me. I'm seeing all actions except the router. It must mean I have something else setup differently. I'm going to have a closer look. I won't give up on this! Thanks for your help @jordenchang55 |
I'm testing both react navigation (till now I found one drawback only on Modals screens where a workaround must implemented) and react native router flux v4 beta 22. (using redux for both)
I like the idea that in react navigation we can navigate to a screen from a reducer when changing the state of the route, it will simply navigate to another screen.
in RNRF, at least in the examples that i saw, we must call the ACTIONS from within the component (view) in order to navigate. for simple apps thats ok. But for larger apps its advisable that the state handles the screen navigation.
any thought?
discussion
The text was updated successfully, but these errors were encountered: