Last active
March 18, 2017 15:08
-
-
Save zwpaper/a1e115e5d262a7ccd485b5424c902f99 to your computer and use it in GitHub Desktop.
[loginPage Handle] #tags: reactnative
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//引入 Loading页面 主页面 登录页等页面组件 | |
constructor(props) { | |
super(props); | |
this.state = { 登录状态: 等待检查 }; | |
} | |
componentDidMount() { | |
this.检查登录(); // 比如调用asyncstorage | |
} | |
检查登录() { | |
if(经过检查后是已登录状态) { | |
this.setState({ 登录状态: 已登录 }); | |
} | |
else { | |
this.setState({ 登录状态: 未登录 }); | |
} | |
} | |
render() { | |
const { 登录状态 } = this.state; | |
switch(登录状态) { | |
case 等待检查: | |
return <Loading页面 />; | |
case 已登录: | |
return <主页面 />; | |
case 未登录: | |
return <登录页 />; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment