React-native-router-flux: Unable to navigate to Scene with Actions.key

Created on 2 Oct 2017  ·  27Comments  ·  Source: aksonov/react-native-router-flux

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

Most helpful comment

Did you not read my bug report. I already said i tried all variations of
function call in onPress. None of them are working. This bug should not be
closed
On Wed, Oct 4, 2017 at 7:04 AM Miguel notifications@github.com wrote:

Closed #2452
https://github.com/aksonov/react-native-router-flux/issues/2452.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/aksonov/react-native-router-flux/issues/2452#event-1278024686,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AExqBzCx-Iob0GmrHAgofYBrCO0rfIsmks5so5BkgaJpZM4Pq_EX
.

All 27 comments

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

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

Did you not read my bug report. I already said i tried all variations of
function call in onPress. None of them are working. This bug should not be
closed
On Wed, Oct 4, 2017 at 7:04 AM Miguel notifications@github.com wrote:

Closed #2452
https://github.com/aksonov/react-native-router-flux/issues/2452.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/aksonov/react-native-router-flux/issues/2452#event-1278024686,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AExqBzCx-Iob0GmrHAgofYBrCO0rfIsmks5so5BkgaJpZM4Pq_EX
.

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

"i have tried all permuatations of the call in bold (
{ACTIONS.LoginScreen}, {ACTIONS.LoginScreen()} etc"

So yes your suggestion has been tried and it does not work.
On Wed, Oct 4, 2017 at 7:43 AM Miguel notifications@github.com wrote:

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


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/aksonov/react-native-router-flux/issues/2452#issuecomment-334178831,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AExqB29BEl7KRIO-9msCWom9apoCUsxcks5so5mtgaJpZM4Pq_EX
.

What Scene are you at trying to navigate to LoginScreen?

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

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

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.

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

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

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

Do you mean wrongly typed Actions.AddEmployee() ?

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

You tried another action staring with uppercase

10 окт. 2017 г., в 19:18, Karan Wadhwa notifications@github.com написал(а):

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


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

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.

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!

@karanwadhwa did you solve this?

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
https://github.com/aksonov/react-native-router-flux/issues/2452#issuecomment-349473903,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AF_I2LLdXlKj4VUpcLOWNGnRx4uWdlXqks5s9c7igaJpZM4Pq_EX
.

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.

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?

Any status on this issue?

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

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

Thanks lot @gagantaneja

use Actions.anotherPageinstead of Actions.anotherPage()

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

use Actions.anotherPageinstead of Actions.anotherPage()

thank a lot

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kirankalyan5 picture kirankalyan5  ·  3Comments

wootwoot1234 picture wootwoot1234  ·  3Comments

rafaelcorreiapoli picture rafaelcorreiapoli  ·  3Comments

vinayr picture vinayr  ·  3Comments

willmcclellan picture willmcclellan  ·  3Comments