Hello. I do authorization in react native. I use the routing module for the react native router flux. Here is the initial component.

export default class authreactnative extends Component { state = { loggedIn:false, } componentWillMount = () => { firebaseApp.auth().onAuthStateChanged((user) => { this.setState({ loggedIn:!!user, }); }); } render() { const { loggedIn } = this.state; const rootSelector = () => loggedIn ? 'home' : 'login'; return ( <Router> <Scene key="root" tabs={true} selector={rootSelector}> <Scene key="login" > <Scene key="authuser" initial={true} component={Auth} title="auth"/> </Scene> <Scene key="home"> <Scene key="appuser" initial={true} component={App} title="app"/> </Scene> </Scene> </Router> ); } } 

The login scene always works, although I manually changed the state, it always opens the login. After successful authorization, there are no errors, but it does not throw on the home scene I need. The console after authorization writes

 Key authuser is already defined! Key login is already defined! Key appuser is already defined! Key home is already defined! Key root is already defined! 

What is the problem?

    1 answer 1

    To navigate between scenes, you need to use Actions. Example

     export default class authreactnative extends Component { componentWillMount = () => { firebaseApp.auth().onAuthStateChanged((user) => { if(user){ Actions.home.appuser();// если есть вложеность Scene нужно писать полный путь Actions.Scene1.Scene2....() }else{ Actions.login.authuser(); } }); } render() { return ( <Router> <Scene key="root" tabs={true}> <Scene key="login" > <Scene key="authuser" initial={true} component={Auth} title="auth"/> </Scene> <Scene key="home"> <Scene key="appuser" component={App} title="app"/> </Scene> </Scene> </Router> ); } }