1 Star 0 Fork 1

万少/txjy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
App.js 1.11 KB
一键复制 编辑 原始数据 按行查看 历史
万少 提交于 2020-06-15 10:40 . 存放用户信息到mobx中
import React, { Component } from 'react';
import { View, AsyncStorage } from 'react-native';
import Nav from "./src/nav";
import Geo from "./src/utils/Geo";
import RootStore from "./src/mobx";
import UserStore from "./src/mobx/userStore";
import { Provider } from "mobx-react";
import JMessage from "./src/utils/JMessage";
class App extends Component {
state = {
isInitGeo: false
}
async componentDidMount() {
// 获取缓存中的用户数据
const strUserInfo = await AsyncStorage.getItem("userinfo");
const userinfo = strUserInfo ? JSON.parse(strUserInfo) : {};
// 判断 有没有token
if (userinfo.token) {
// 把缓存中的数据 存一份到mobx中
RootStore.setUserInfo(userinfo.mobile, userinfo.token, userinfo.userId);
// 极光初始化
JMessage.init();
}
await Geo.initGeo();
this.setState({ isInitGeo: true });
}
render() {
return (
<View style={{ flex: 1 }}>
<Provider RootStore={RootStore} UserStore={UserStore} >
{this.state.isInitGeo ? <Nav></Nav> : <></>}
</Provider>
</View>
);
}
}
export default App;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ukSir/txjy.git
git@gitee.com:ukSir/txjy.git
ukSir
txjy
txjy
master

搜索帮助