-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
66 lines (62 loc) · 1.42 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React,{Component} from 'react';
import { AsyncStorage } from "react-native"
import MainStack from './src/components/Main';
// import A from './src/test'
import Login from './src/app/login_register/login';
import {createSwitchNavigator} from 'react-navigation';
export default class App extends Component {
constructor(props){
super(props)
this.state = {
logined:false,
user:null
}
this._asyncAppStatus = this._asyncAppStatus.bind(this)
// this._afterLogin = this._afterLogin.bind(this)
}
componentDidMount(){
this._asyncAppStatus()
}
_asyncAppStatus(){
let that = this
AsyncStorage.getItem('user')
.then((data) => {
console.info('存储',data)
if(data){
// s
// user[1].logined
// console.log(logined);
that.setState({
logined:true,
})
}
})
}
render() {
// console.log('asd',!this.state.logined)
// console.log('sb',AsyncStorage.getItem('user'))
if(!this.state.logined){
// return <Login afterLogin={this._afterLogin}></Login>
return <RootStack></RootStack>
}else{
return <MainStack></MainStack>
}
}
}
const RootStack = createSwitchNavigator(
{
Main: {
screen: Login,
},
MyModal: {
screen: MainStack,
},
}
);