Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
nullify = nextAppState => {
console.log("App changed to: ", nextAppState);
if (nextAppState === "inactive") {
// Writing it 'null'
this.setState({ pwd: stringToU8("000000000000000000000000") });
// Removing it's refs do the GC can clean it
delete this.state.pwd;
// Construct a reset action for the naviggator
const resetAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({
routeName: "Initial"
})
]
});
this.props.navigation.dispatch(resetAction);
console.log("Key Cleaned & Rerouted to login");
}
};
import React, {Component} from 'react';
import {View, Text, StyleSheet, TextInput} from 'react-native';
import {connect} from 'react-redux'; // 引入connect函数
import * as loginAction from './loginAction';// 导入action方法
import {NavigationActions} from 'react-navigation';
import {THEME_BACKGROUND, THEME_LABEL, THEME_TEXT} from '../assets/css/color';
import CButton from '../common/button';
// 清空导航记录,跳转到首页
const resetAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({routeName: 'Main'})
]
});
class LoginPage extends Component {
static navigationOptions = {
header: null
};
mobile = '13510005217';
password = '123456';
constructor(props) {
_backHome = () => {
this.props.navigation.dispatch(
NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: "Home"}),
],
})
)
}
handleSetupTermsCompleted: async () => {
const termsVersion = await ChffrPlus.readParam(Params.KEY_LATEST_TERMS_VERSION);
ChffrPlus.writeParam(Params.KEY_ACCEPTED_TERMS_VERSION, termsVersion);
dispatch(NavigationActions.reset({
index: 0,
key: null,
actions: [
NavigationActions.navigate({
routeName: 'SetupPair',
})
]
}))
},
handleSetupTermsBackPressed: () => {
onLogin = () => {
this.props.showDialog();
const resetAction = NavigationActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName: 'RootScreen' })]
});
setTimeout(() => {
this.props.hideDialog();
InteractionManager.runAfterInteractions(() => {
this.props.navigation.dispatch(resetAction);
LayoutAnimation.linear();
});
}, 1500);
};
render() {
logout() {
const { updateCurrentUser, navigation, clearHomeData } = this.props;
updateCurrentUser({});
clearHomeData();
const navigateAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'LoginScreen' }),
],
});
navigation.dispatch(navigateAction);
}
navigateToHome() {
const resetAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'Home' })
]
});
this.props.navigation.dispatch(resetAction);
}
const reset = (navigation, routeName, params = {}) => {
const resetAction = NavigationActions.reset({
index: 0,
actions: [NavigationActions.navigate({routeName, params})]
});
navigation.dispatch(resetAction);
};
navigateToLoginPage() {
const resetAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'Login' })
]
});
this.props.navigation.dispatch(resetAction);
}
navigateHome: async () => {
ChffrPlus.writeParam(Params.KEY_HAS_COMPLETED_SETUP, "1");
const isPassive = await checkIsPassive();
let destRoute = 'Onboarding';
if (isPassive) {
destRoute = 'Home';
}
dispatch(NavigationActions.reset({
index: 0,
key: null,
actions: [
NavigationActions.navigate({ routeName: destRoute })
]
}));
},
acceptTerms: async () => {