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

Unable to navigate to Scene with Actions.key #2452

Closed
nikitph opened this issue Oct 2, 2017 · 27 comments
Closed

Unable to navigate to Scene with Actions.key #2452

nikitph opened this issue Oct 2, 2017 · 27 comments

Comments

@nikitph
Copy link

nikitph commented Oct 2, 2017

Version

Tell us which versions you are using:

  • react-native-router-flux v4. latest
  • react-native v0.47.2

Expected behaviour

expect ACTIONS.KEY to take me to the necessary scene.

Actual behaviour

nothing happens. no errors i just stay stuck on the same scene.

Steps to reproduce

class NavigationRouter extends Component {
  render() {
    return (
      <Router>
        {/*<Scene key='drawer' component={NavigationDrawer} open={false}>*/}
          {/*<Scene key='drawerChildrenWrapper' navigationBarStyle={Styles.navBar} titleStyle={Styles.title}*/}
                 {/*leftButtonIconStyle={Styles.leftButton} rightButtonTextStyle={Styles.rightButton}>*/}
        <Stack key="root">

        <Scene key='Dashboard' component={Dashboard} hideNavBar/>
            <Scene key='SignUpDetailsScreen' component={SignUpDetailsScreen} hideNavBar/>
            <Scene key='ResetPasswordScreen' component={ResetPasswordScreen} hideNavBar/>
            <Scene key='SignUpScreen' component={SignUpScreen} hideNavBar/>
            <Scene key='LoginScreen' component={LoginScreen} hideNavBar/>
            <Scene initial key='WalkThroughScreen' component={WalkThroughScreen} hideNavBar/>
        {/*
        </Scene>
        </Scene>*/}
        </Stack>
      </Router>
    )
  }
}

export default NavigationRouter

and here is where i am calling it

 <RectangleButton
              onPress={()=>Actions.LoginScreen}
              text="LOGIN"
              type="primary"
              height={75}
              backgroundColors={['#BF9C65', '#CEA76A']}
              gradientStart={{ x: 0.5, y: 1 }}
              gradientEnd={{ x: 1, y: 1 }}
            >
            </RectangleButton>

i have tried these permutations of the onPress:
{() => Actions.LoginScreen}
{() => Actions.LoginScreen()}
{Actions.LoginScreen}

So thats not the problem. one gentleman solved this by going to v3. thats not working for me

@josiahstapleton
Copy link

josiahstapleton commented Oct 3, 2017

I am also getting this error. Can't navigate to another scene and no error is displayed. RN 0.48.3, react-native-router-flux 4.0.0-beta.21

@mcabs3
Copy link
Collaborator

mcabs3 commented Oct 4, 2017

onPress={()=>Actions.LoginScreen} needs to be onPress={()=>Actions.LoginScreen()}

@mcabs3 mcabs3 closed this as completed Oct 4, 2017
@nikitph
Copy link
Author

nikitph commented Oct 4, 2017 via email

@mcabs3
Copy link
Collaborator

mcabs3 commented Oct 4, 2017

you said you tried {ACTIONS.LoginScreen()}, that isn't the same as {() => Actions.LoginScreen()}

@nikitph
Copy link
Author

nikitph commented Oct 4, 2017 via email

@mcabs3 mcabs3 changed the title ACTIONS.KEY does not work. Unable to navigate to Scene with Actions.key Oct 4, 2017
@mcabs3
Copy link
Collaborator

mcabs3 commented Oct 4, 2017

What Scene are you at trying to navigate to LoginScreen?

@mcabs3 mcabs3 reopened this Oct 4, 2017
@mcabs3
Copy link
Collaborator

mcabs3 commented Oct 4, 2017

I have updated your description of the problem to better explain your situation, please review it when you have a moment.

@josiahstapleton
Copy link

I also get this issue. Before it worked fine on React-native-router-flux 3.38. I then updated to the latest version of react-native-router-flux and now as mentioned in this open issue, I can't change scenes using ACTIONS.KEY. I tried with RN 0.48.3 and 0.48.4 and I get the same issue

@karanwadhwa
Copy link

karanwadhwa commented Oct 4, 2017

I've been facing a similar issue.

      <Router>
      <Scene key="root" hideNavBar>

        {/* Authentication Bucket */}
        <Scene key="auth" >
          <Scene key="login" component={LoginForm} title="ManagerLogin" initial />
        </Scene>

        {/* Main Bucket */}
        <Scene key="main" >
          <Scene 
            rightTitle=" Add"
            onRight={() => Actions.AddEmployee()} 
            key="employeeList" 
            component={EmployeeList} 
            title="Employee List" 
            initial
          />
          <Scene key="addEmloyee" component={AddEmployee} title="Add Employee" />  
        </Scene>

         {/* Test Bucket */}
        <Scene key="moo" >
          <Scene key="add" component={AddEmployee} title="Add Employee" />  
          <Scene key="emp" component={EmployeeList} title="Employee" />
        </Scene>

      </Scene>
    </Router>

in the above code when I click on rightTitle it gives me the following error: `undefined is not a function (evaluating '_reactNativeRouterFlux.Actions.addEmployee()')


Case2:
when I call Action.key directly from the body like so:
<Text onPress={Actions.moo}>EmployeeList</Text>
it works perfectly and navigates to the first scene in the 'moo' scene.
but if i change it to <Text onPress={() => Actions.moo()}>EmployeeList</Text> it doesn't work


Case 2.1:
similarly, if I want to access the addEmployee nested within moo neither of the options below work:
<Text onPress={Actions.addEmployee}>EmployeeList</Text>
<Text onPress={() => Actions.addEmployee()}>EmployeeList</Text>


Case 3:
Actions.key() works fine in this scenario:
firebase.auth().signInWithEmailAndPassword(email, password) .then(user => { dispatch({ type: LOGIN_USER_SUCCESS, payload: user }); Actions.main(); })


P.S. i only get an error when i add Actions.key to onRight whereas there's simply no response in other cases.
I might be wrong and probably theres nothing broken in RNRF but i just cant seem to figure this out.

@schlaegerz
Copy link

I am having the same problem. Happened when I tried to move to the beta since 3.38 does not work on RN 0.49

@aksonov
Copy link
Owner

aksonov commented Oct 10, 2017

Please read docs for v4 - you should not have both component and children defined. Your 'Dashboard' is considered as child, not container.

@aksonov aksonov closed this as completed Oct 10, 2017
@karanwadhwa
Copy link

hey @aksonov that doesn't solve my issue. I don't have component defined in my container.

@aksonov
Copy link
Owner

aksonov commented Oct 10, 2017

Do you mean wrongly typed Actions.AddEmployee() ?

@karanwadhwa
Copy link

AddEmployee is the component name while addEmployee is the key so Actions.addEmployee() should work but it doesnt.

@aksonov
Copy link
Owner

aksonov commented Oct 10, 2017 via email

@karanwadhwa
Copy link

no i didnt. please refer to this

I've been facing a similar issue.

      <Router>
      <Scene key="root" hideNavBar>

        {/* Authentication Bucket */}
        <Scene key="auth" >
          <Scene key="login" component={LoginForm} title="ManagerLogin" initial />
        </Scene>

        {/* Main Bucket */}
        <Scene key="main" >
          <Scene 
            rightTitle=" Add"
            onRight={() => Actions.AddEmployee()} 
            key="employeeList" 
            component={EmployeeList} 
            title="Employee List" 
            initial
          />
          <Scene key="addEmloyee" component={AddEmployee} title="Add Employee" />  
        </Scene>

         {/* Test Bucket */}
        <Scene key="moo" >
          <Scene key="add" component={AddEmployee} title="Add Employee" />  
          <Scene key="emp" component={EmployeeList} title="Employee" />
        </Scene>

      </Scene>
    </Router>

in the above code when I click on rightTitle it gives me the following error: `undefined is not a function (evaluating '_reactNativeRouterFlux.Actions.addEmployee()')


Case2:
when I call Action.key directly from the body like so:
<Text onPress={Actions.moo}>EmployeeList</Text>
it works perfectly and navigates to the first scene in the 'moo' scene.
but if i change it to <Text onPress={() => Actions.moo()}>EmployeeList</Text> it doesn't work


Case 2.1:
similarly, if I want to access the addEmployee nested within moo neither of the options below work:
<Text onPress={Actions.addEmployee}>EmployeeList</Text>
<Text onPress={() => Actions.addEmployee()}>EmployeeList</Text>


Case 3:
Actions.key() works fine in this scenario:
firebase.auth().signInWithEmailAndPassword(email, password) .then(user => { dispatch({ type: LOGIN_USER_SUCCESS, payload: user }); Actions.main(); })


P.S. i only get an error when i add Actions.key to onRight whereas there's simply no response in other cases.
I might be wrong and probably theres nothing broken in RNRF but i just cant seem to figure this out.

@renatofilipov
Copy link

I also get the same issue... when I run the "demo app", it works. But when I import to my working (ejected) app, it doesn't.

Any hints?

Thanks!

@jeomora
Copy link

jeomora commented Dec 5, 2017

@karanwadhwa did you solve this?

@renatofilipov
Copy link

renatofilipov commented Dec 5, 2017 via email

@gagantaneja
Copy link

Running into exactly same issue . It ran smoothly for me earlier with the same code but when i created a new project with the same code, it stopped working on some places . Please do help.

@gagantaneja
Copy link

I also get the same issue... when I run the "demo app", it works. But when I import to my working (ejected) app, it doesn't.

Any hints?

Thanks!

Yes, I have just solved it. Thanks! Em 5 de dez de 2017 18:16, "Jeovany" notifications@github.com escreveu:

@karanwadhwa https://github.com/karanwadhwa did you solved this? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#2452 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AF_I2LLdXlKj4VUpcLOWNGnRx4uWdlXqks5s9c7igaJpZM4Pq_EX .

Can you please tell me how to solve this?

@preetampatil3d
Copy link

Any status on this issue?

@gagantaneja
Copy link

This is an issue with the latest update of the library. Trying adding both the scenes under the same parent scene. If both of them exist under different scenes. Try : Actions.parentKey; Actions.scene

@preetampatil3d
Copy link

It worked . .
Old code :
onPress={() => { Actions.map() }}
Modified code :
onPress={() => { Actions.menu();Actions.map() }}

Thanks lot @gagantaneja

@hussein661
Copy link

use Actions.anotherPage instead of Actions.anotherPage()

@sittes
Copy link

sittes commented Sep 21, 2019

eu não conseguir chamar a função do meu botão

@nmhoan76
Copy link

use Actions.anotherPage instead of Actions.anotherPage()

thank a lot

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