Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function nav(state = initialNavState, action) {
let nextState;
switch (action.type) {
case 'Login':
nextState = AppNavigator.router.getStateForAction(
NavigationActions.back(),
state
);
break;
case 'Logout':
nextState = AppNavigator.router.getStateForAction(
NavigationActions.navigate({ routeName: 'Login' }),
state
);
break;
default:
nextState = AppNavigator.router.getStateForAction(action, state);
break;
}
// Simply return the original `state` if `nextState` is null or undefined.
return nextState || state;
backHandle = () => {
const currentScreen = getActiveRouteName(this.props.router)
if (currentScreen === 'Login') {
return true
}
if (currentScreen !== 'Home') {
this.props.dispatch(NavigationActions.back())
return true
}
return false
}
goBack = () => {
const { navigation } = this.props
navigation.dispatch(NavigationActions.back())
MainStore.appState.setShouldShowUpdatePopup(false)
MainStore.appState.setLastestVersionRead(this.lastestVersion)
MainStore.appState.save()
}
onSubmit: ({ createTransfer, navigation, ...props }) => () => {
createTransfer({
...R.pick(fields, props),
from: R.prop('id', props.from),
to: R.prop('id', props.to),
});
navigation.dispatch(NavigationActions.back());
},
}),
const goBack = () => {
navigation.dispatch(NavigationActions.back())
}
return {
export function backOneScreen(navigation){
const backAction = NavigationActions.back();
navigation.dispatch(backAction);
}
{
params.cancelProfileUpdate()
if (params.backTo) {
navigation.dispatch(NavigationActions.navigate({ routeName: params.backTo }))
} else {
navigation.dispatch(NavigationActions.back())
}
}} />
dispatch: action => {
if (action.type === NavigationActions.back().type) {
onNavigateBack()
}
},
})}
onBackPress = () => {
const { dispatch, nav } = this.props
if (nav.routes[0].index === 0) {
if (this.lastBackPressed && this.lastBackPressed + 2000 >= Date.now()) {
BackHandler.exitApp()
return true
}
this.lastBackPressed = Date.now()
Toast.show('再按一次退出应用')
return true
} else {
dispatch(NavigationActions.back())
return true
}
}
backHandle = () => {
const currentScreen = getCurrentScreen(this.props.router)
if (currentScreen === 'Login') {
return true
}
if (currentScreen !== 'Home') {
this.props.dispatch(NavigationActions.back())
return true
}
return false
}