I would like to be able to navigate by dispatching actions, so I can use RNRF with redux-sagas this way:
import {Actions as NavigationActions} from 'react-native-router-flux'
export function * login({username, password}) {
const response = yield call(API.login, username, password)
if (response.ok) {
yield put(NavigationActions.mainScreen()) // <----- here
}
else {
yield put(NavifationActions.errorScreen()) // <---- here
}
}
calling NavigationActions.XXX() already calls dispatch. I would like to have the object it calls dispatch with so I could call yield put() it in my sagas.
I had a similar problem and at least for me using call instead of put did the job
So you'd do something like
import {Actions as NavigationActions} from 'react-native-router-flux'
export function * login({username, password}) {
const response = yield call(API.login, username, password)
if (response.ok) {
yield call(NavigationActions.mainScreen) // <----- here
}
else {
yield call(NavifationActions.errorScreen) // <---- here
}
}
+1 do u have more examples on how saga works? like setting up the sagas
Thanks @holden-caulfield
@jjhesk, you should take a look at the official documentation of redux-sagas
Most helpful comment
I had a similar problem and at least for me using
callinstead ofputdid the jobSo you'd do something like