aksonov / aksonov/react-native-router-flux
How to set initial scene while checking the state of the user is login or not?
- 主要语言
- JavaScript
- 星标
- 8.9k
- 派生
- 2.1k
- PR 合并指标
- 30 天内没有已合并 PR
描述
### Version
- react-native-router-flux : "^4.0.6"
- react: "16.6.3",
- react-native: "0.58.4",
### Expected behaviour
I am using this module it's working fine. I am storing a login value in **AsyncStorage**. I have 2 screens **Login** and **Home** after login i am checking value in initial screen and it returns home screen initially.
### Actual behaviour
I'm facing an issue with this code it always firstly returns login screen after it returns home screen.
The screen looks like glitches.
### Code
```
import React, { Component } from "react";
import {
Platform,
StyleSheet,
Text,
View,
AsyncStorage,
ActivityIndicator
} from "react-native";
import { Scene, Router, Stack } from "react-native-router-flux";
import Login from "./Src/Initial.js";
import Home from "./Src/Home.js";
type Props = {};
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
initial: true,
homeRouting: false
};
}
async componentWillMount() {
await AsyncStorage.getItem("TokenDetails", (err, result) => {
if (result) {
this.setState({
initial: false,
homeRouting: true
});
} else {
this.setState({
initial: true,
homeRouting: false
});
}
});
}
render() {
return (
{this.state.homeRouting ? (
) : (
)}
);
}
}
```
Here is my screenshot:

贡献指南
评估
这个 Issue 还没有评估数据。