React-native-router-flux: Cant return a initial Scene from Drawer

Created on 13 Oct 2016  路  15Comments  路  Source: aksonov/react-native-router-flux

Version

Tell us which versions you are using:

  • react-native-router-flux v3.31.2
  • react-native v0.34.1

My index tree

<Router>
   <Scene key="root" >
      <Scene key='Login' component={Login} />
      <Scene key='Drawer' component={SideDrawer} />
         <Scene key='drawerRoot' />
             <Scene key='Home' component={Home} />
         </Scene>
      </Scene>
   </Scene> 
</Router>

Expected behaviour

Go to initial Scene on LogOut

Actual behaviour

If i put Actions.Login() navigation go to Drawer.
If i put Actions.Login({type: 'reset'}) app crash with: Cannot read property sceneKey of undefined

Steps to reproduce

  1. Init in Login
  2. Actions.Drawer({type: 'reset'})
  3. From home: Actions.Login({type: 'reset'})
  4. App crash with error: Cannot read property sceneKey of undefined

How can i fix it?

Most helpful comment

Ok the error is for this functions of my SideDrawercomponent:

        onOpen={()=>Actions.refresh({key:state.key, open: true})}
        onClose={()=>Actions.refresh({key:state.key, open: false})}

For fix it, i only have to remove drawer.close(); from LogOut onPress button in SideDrawerContent.js

Thanks for help @dragfire

All 15 comments

Some help?

Do like this Actions.Drawer() without {type: 'reset'}.

If i dont use {type: 'reset'}, user can go back with Android back button. I need add it after login.

See this issue #1146

But {type: 'reset'} should work fine. I use it in other app with Drawer and TabBar and dont have this issue.

Haven't done much on Android. Try this let's see if it works Actions.root({key: 'Login'})

When i put Actions.Login() orActions.root({key: 'Login'})without reset, navigation flash 1 sec in Login component but after navigate to Drawer.

on Logout: Actions.root({key: 'Login', type: 'reset'})

Mine is working fine on iOS. IDK.

With Actions.root({key: 'Login', type: 'reset'}) give same error: Cannot read property 'sceneKey' of undefinded

I have other project with router-flux working fine, but in this project i cant.

The problem is you have already reset the scene history stack after login so login scene is no longer in the stack, it is empty. And you are looking for a sceneKey which is no longer in the stack.

But i want start new stack from "Login" component. If i do Action.Login without reset, Login scene is presented a few seconds. But after going back to Drawer

Ok the error is for this functions of my SideDrawercomponent:

        onOpen={()=>Actions.refresh({key:state.key, open: true})}
        onClose={()=>Actions.refresh({key:state.key, open: false})}

For fix it, i only have to remove drawer.close(); from LogOut onPress button in SideDrawerContent.js

Thanks for help @dragfire

TypeError: Cannot read property 'eventName' of undefined, I got the error while using Actions.root({key: 'Login', type: 'reset'});
Can Anyone tell me how can i solve it??

@TRIPTI-JAIN did you even have a look on the Example project?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tonypeng picture tonypeng  路  3Comments

GCour picture GCour  路  3Comments

sreejithr picture sreejithr  路  3Comments

xnog picture xnog  路  3Comments

kirankalyan5 picture kirankalyan5  路  3Comments