からログインビューにリダイレクトするはネイティブリアクト - 。私は、ユーザーがアプリケーションの起動時にログインしているかどうかを検出し、ログインしていない場合は、ログイン画面に彼をリダイレクトしようとしていますどのようにcomponentWillReceiveProps
import * as AuthView from '../modules/auth/AuthView';
const AppView = React.createClass({
propTypes: {
isReady: PropTypes.bool.isRequired,
isLoggedIn: PropTypes.bool.isRequired,
dispatch: PropTypes.func.isRequired
},
componentDidMount() {
snapshotUtil.resetSnapshot()
.then(snapshot => {
const {dispatch} = this.props;
if (snapshot) {
dispatch(SessionStateActions.resetSessionStateFromSnapshot(snapshot));
} else {
dispatch(SessionStateActions.initializeSessionState());
}
store.subscribe(() => {
snapshotUtil.saveSnapshot(store.getState());
});
});
},
componentWillReceiveProps({isReady, isLoggedIn}) {
if (!this.props.isReady) {
if (isReady && !isLoggedIn) {
console.warn("Not logged in, trying to show login screen here...");
AuthView.showLoginView();
}
}
},
render() {
if (!this.props.isReady) {
return (
<View>
<ActivityIndicator style={styles.centered}/>
</View>
);
}
return (
<View style={{flex: 1}}>
<NavigationViewContainer />
</View>
);
}
});
そして、私のAuthViewはこのようになります:
export function showLoginView() {
var loginView = <View>
<Text>
This is a Login View
</Text>
</View>;
return loginView;
}
出力は空白です。 http://i.imgur.com/6CgvOGW.png
警告メッセージ(console.warn)が表示され、「ActivityIndicator」が表示されています。しかし、ログインパネルではありません。
私の質問は、showLoginView()関数を変更してフルスクリーンのログインビューを表示する方法です。
私は同じ結論に近づいていました!ご確認、ありがとうございます。私はそれを行う他の方法があるかどうかを待つ。 btw、私がペーストしたコードは、私が理解しようとしているpepperoni-app-kitの一部です。 https://github.com/futurice/pepperoni-app-kit/blob/master/src/modules/AppView.js#L36と似たようなことをしています。しかし、その行のログインを表示するためにネイティブモジュールを使用しているようです –