Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

goBack or pop not work in first time #2878

Closed
dborzouei opened this issue Feb 12, 2018 · 7 comments
Closed

goBack or pop not work in first time #2878

dborzouei opened this issue Feb 12, 2018 · 7 comments

Comments

@dborzouei
Copy link

Version

^4.0.0-beta.28

 <Router     createReducer={this.reducerCreate}>
                <Scene>
                    <Drawer
                        key="SearchScreen"
                        contentComponent={() => <DrawerComponent goToScreen={this.goToScreen}/>}
                        drawerPosition="right"
                        hideNavBar
                        drawerUnderNavBar={true}
                        initial
                    >
                        <Scene  >
                            <Scene key="SearchScreen1" component={ScreenSearchStep1} initial/>
                            <Scene key="SearchScreen2" component={ScreenSearchStep2} />
                            <Scene key="SearchScreen3" component={ScreenSearchStep3}/>
                            <Scene key="MelkScreen" component={ScreenMelk}/>


                        </Scene>
                    </Drawer>
                    <Scene key='AppScreen' hideNavBar>
                        <Scene key="ContactScreen" component={ContactScreen}/>
                        <Scene key="AboutScreen" component={AboutScreen}/>
                    </Scene>
                    <Scene key='UserScreen' hideNavBar >
                        <Scene key="LoginScreen" component={ScreenLogin}  />
                        <Scene key="ScreenRegister" component={ScreenRegister} />
                    </Scene>

                    {/*<Scene key="SplashScreen" component={ScreenSplash} hideNavBar initial/>*/}


                    {/*<Scene  hideNavBar initial>*/}

                    {/*</Scene>*/}

                </Scene>

            </Router>

my initial screen is "SearchScreen1" in Drawer Scene,
when i use Actions.LoginScreen () for go to the login screen is work fine , but when i click back button
back button work fine but not go to SearchScreen1, stay in Login screen, when I click again on back button in login screen this time is work and scrren change and navigate to SearchScreen1
i try back with Actions.pop() or navigation.goBack() , But it does not matter
why can not back in first time ?

@dborzouei
Copy link
Author

@aksonov , @charpeni

@Blapi
Copy link
Collaborator

Blapi commented Feb 13, 2018

Hey @dborzouei, please add this in your code so you can see what really happens :

const reducerCreate = (params) => {
  const defaultReducer = new Reducer(params)
  return (state, action) => {
    console.log('Action :', action)
    console.log('State :', state)
    return defaultReducer(state, action)
  }
}

What does your reducerCreate function tells you in the logs? Can you tell me please? Because I see you have it.

Btw, you need to have your first Scene to have key='root' :) The Scene which contains all your scenes

@dborzouei
Copy link
Author

dborzouei commented Feb 17, 2018

hi @Blapi , thanks for reply , i fixed key='root'
for first Scene
my modified code is

const reducerCreate = (params) => {
  const defaultReducer = new Reducer(params)
  return (state, action) => {
    console.log('Action :', action)
    console.log('State :', state)
    return defaultReducer(state, action)
  }
}
<Router createReducer={reducerCreate}>
                <Scene key='root'>
                    <Drawer
                        key="SearchScreen"
                        contentComponent={() => <DrawerComponent goToScreen={this.goToScreen}/>}
                        drawerPosition="right"
                        hideNavBar
                        drawerUnderNavBar={true}
                        initial
                    >
                        <Scene  >
                            <Scene key="SearchScreen1" component={ScreenSearchStep1} initial/>
                            <Scene key="SearchScreen2" component={ScreenSearchStep2} />
                            <Scene key="SearchScreen3" component={ScreenSearchStep3}/>
                            <Scene key="MelkScreen" component={ScreenMelk}/>
                        </Scene>
                    </Drawer>
                    <Scene key='AppScreen' hideNavBar>
                        <Scene key="ContactScreen" component={ContactScreen}/>
                        <Scene key="AboutScreen" component={AboutScreen}/>
                    </Scene>
                    <Scene key='UserScreen' hideNavBar >
                        <Scene key="LoginScreen" component={ScreenLogin}  />
                        <Scene key="ScreenRegister" component={ScreenRegister} />
                    </Scene>
                </Scene>

            </Router>

when i go to Login Screen and use navigation.goBack to back ScreenSearchStep1Action
image1
never returned !!!
but when i use Actions.pop() or back button hardware on emulator
image2

@dborzouei
Copy link
Author

hi @Blapi
I'm waiting for the result

@Blapi
Copy link
Collaborator

Blapi commented Feb 19, 2018

Well, it's working with Actions.pop() so it's ok no?

@Blapi Blapi closed this as completed Feb 19, 2018
@dborzouei
Copy link
Author

no , this not work . When I'm pressed the back button 2 times . this work
Of course, with the code Actions.pop(). in first time not back to main screen .
if i use navigation.goBack() , this never back

@Blapi
Copy link
Collaborator

Blapi commented Feb 23, 2018

So use Actions.pop() no ???? Why keep using navigation.goBack() if it's not working but it's working as expected with Actions.pop() ?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants