attentiveness / reading

iReading App Write In React-Native
https://richardcao.me/2016/07/05/Talk-About-Reading/
Apache License 2.0
3.42k stars 881 forks source link

请问下怎么在sagas中实现跳转页面? #136

Closed forrest23 closed 5 years ago

forrest23 commented 5 years ago

应用场景:在登陆操作时,在sagas中判断是否登陆成功,成功则跳转到主页,代码如下: export function* requestLogin(loading, body) { try { yield put(fetchLogin(loading)); const loginResult = yield call( RequestUtil.request, ${LOGIN}, 'post', body, false ); const errorMessage = loginResult.error_description; if (errorMessage && errorMessage !== '') { yield put(receiveLogin({})); yield ToastUtil.showShort(errorMessage); } else { yield put(receiveLogin(loginResult)); yield call(StorageUtil.saveUser, loginResult); yield put(NavigationActions.navigate({ routeName: 'Home' })); } } catch (error) { yield put(receiveLogin({})); ToastUtil.showShort('网络发生错误,请重试' + error); } }

我是用了yield put(NavigationActions.navigate({ routeName: 'Home' })); 这句代码来跳转,结果无效?想问下这个应该怎么写才对?其他代码都是reading一样的,有空能看下吗?谢谢 @Richard-Cao

Richard-Cao commented 5 years ago

跳转无效有什么log吗?