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

There is no route defined for key key0. Must be one of: 'key3','< clone view key >' (nested scenes) #2439

Closed
brandonjyuhas opened this issue Sep 26, 2017 · 21 comments

Comments

@brandonjyuhas
Copy link

Version

Tell us which versions you are using:

  • react-native-router-flux v4.0.0-beta.18 (v3 is not supported)
  • react-native v0.47.1

Expected behaviour

I have my router set up like this:

<Router>
  <Scene key='root' hideNavBar>
    <Scene key='onboarding'>
      <Scene key='welcome' component={Welcome} title='Welcome' />
      <Scene key='selectItems' component={SelectItems} title='Select Items' />
    </Scene>
    <Scene
      key='main'
      showLabel={false}
      tabs={true}
      initial={this.props.user.onboarded}
      showIcon={true}
      iconStyle={{width: 100, height: 30}}
    >
      <Scene key='tab1' title='My Items' icon={TabIcon} iconName='glass'>
        <Scene component={MyItems} />
      </Scene>
      <Scene key='tab2' title='Items' icon={TabIcon} iconName='search' initial={true}>
        <Scene component={Feed} />
      </Scene>
      <Scene key='tab3' title='Saved' icon={TabIcon} iconName='heart'>
        <Scene component={SavedItems} />
      </Scene>
    </Scene>
    <Scene key='itemShow' back clone component={ItemShow} />
  </Scene>
</Router>

When the app loads initially (with no persisted data), the scene of key "welcome" is loaded. A button on that component calls Actions.selectItems(), and navigates to the scene of key "selectItems".

The component in SelectItems has a button that calls Actions.main() (as well as firing an action which sets user.onboarded to true).

I'd expect that the scene of key "main" would load, which in turn would load it's initial scene, "tab2".

Actual behaviour

When Actions.main() is called from SelectItems, an error is thrown:

There is no route defined for key key0. Must be one of: 'key3','itemShow'.

However, if the app is reloaded (now that this.props.user.onboarded = true, the app successfully loads to the Feed component.

Note: the reason I have nested the scenes within their tab scenes is that otherwise, when navigating to a clone view, the tab for the scene which you navigated from is replaced with a tab for the clone view (which is reproducible in the Example app by navigating to tab3 and then the echo view. tab3 will disappear).

Steps to reproduce

Please let me know if you need me to fork the example app.

Thanks!!

@brandonjyuhas brandonjyuhas changed the title There is no route defined for key key0. Must be one of: 'key3','itemShow' There is no route defined for key key0. Must be one of: 'key3','itemShow' (nested scenes) Sep 26, 2017
@brandonjyuhas brandonjyuhas changed the title There is no route defined for key key0. Must be one of: 'key3','itemShow' (nested scenes) There is no route defined for key key0. Must be one of: 'key3','< clone view key >' (nested scenes) Sep 26, 2017
@joel611
Copy link

joel611 commented Sep 27, 2017

Every scene needs a key. Try add key to scene within tabs(myitem, feed, saveditem)

@brandonjyuhas
Copy link
Author

@joel611 that worked! Thanks so much!

@greenzeal
Copy link

worked for me also! thanks!

@ghost
Copy link

ghost commented Dec 2, 2017

I just had to replace my ActionConst.RESET with ActionConst.REPLACE

@hossein-kheirabadi
Copy link

@joel611 that worked! Thanks so much!

@hugoh59
Copy link

hugoh59 commented Mar 9, 2018

I already have a key for all my scenes but still getting that error.

@shamanking
Copy link

shamanking commented Mar 21, 2018

I have same issue, this is my code:

`

  <Scene key="root" hideNavBar >
    <Scene key="auth">
      <Scene key="login" component={LoginForm} title="Please Login" />
    </Scene>
    <Scene key="main">
      <Scene
        key="employeeList"
        rightTitle="Add"
        onRight={() => { Actions.employeeCreate(); }}
        component={EmployeeList}
        title="Employees"
      />
      <Scene key="employeeCreate" component={EmployeeCreate} title="Employee Create" />
    </Scene>
  </Scene>
</Router>`

When I try: Actions.employeeList({ type: 'reset' });
It has error: there is no route define for key employeeList, must be one of 'auth', 'main'

@chelseaisgood
Copy link

@shamanking Same here. I used Actions.main or Actions.pop to resolve this. But I do want to know how to navigate to some scene like employeeList, not the direct sub-scene of the root scene.

@shamanking
Copy link

shamanking commented Mar 26, 2018

@chelseaisgood : Thank you. I call employeeList from Scene employeeCreate. In Scene employeeCreate, I call action like:

`
export const employeeDelete = ({ uid }) => {

const { currentUser } = firebase.auth();
return () => {
   firebase.database().ref(`/users/${currentUser.uid}/employees/${uid}`)
     .remove()
     .then(() => {
         Actions.employeeList();
      });
 };

};
`

If I try: Actions.employeeList({ type: 'reset' }); It has error.

@selvesandev
Copy link

@shamanking Did you solve this issue ?

@abohannon
Copy link

I am also getting this error.

There is no route defined for key key1. Must be one of: 'key2'

Was working fine until I introduced the modal + the additional 'rootPrivate' scene as the docs detail for setting up the modal.

<Router getSceneStyle={this.getSceneStyle}>
        <Scene key="root" hideNavBar>
          <Scene key="public">
            <Scene
              key="login"
              component={LoginForm}
              title="Please Login"
              rightTitle="Sign up"
              onRight={() => Actions.signup()}
              hideNavBar
            />
            <Scene
              key="signup"
              component={SignupForm}
              title="Create Account"
              hideNavBar
            />
          </Scene>
          <Scene key="private" hideNavBar>
            <Modal>
              <Scene key="rootPrivate">
                <Scene
                  key="nearby"
                  component={Nearby}
                  title="Nearby"
                  leftTitle="Settings"
                  onLeft={() => Actions.push('settings')}
                  rightTitle="My places"
                  onRight={() => Actions.userDash()}
                  titleStyle={styles.titleStyle}
                  rightButtonTextStyle={{ color: GREY_DARK }}
                />
                <Scene
                  key="userDash"
                  component={MyPlaces}
                  title="My places"
                  titleStyle={styles.titleStyle}
                  backTitle="Nearby"
                  backButtonTextStyle={{ color: GREY_DARK }}
                  navBarButtonColor={GREY_DARK}
                />
              </Scene>
              <Scene
                key="settings"
                component={Settings}
                title="Settings"
                titleStyle={styles.titleStyle}
                rightTitle="Nearby"
                onRight={() => Actions.pop()}
                direction="leftToRight"
              />
            </Modal>
          </Scene>
        </Scene>
      </Router>

@Blapi
Copy link
Collaborator

Blapi commented May 2, 2018

@abohannon try adding a key to your Modal View ?

@saurabhabh
Copy link

@shamanking @selvesandev I am facing the same issue. Any suggestions as to how to fix it?

@tlesick
Copy link

tlesick commented Jun 3, 2018

Try Action.pop()

@JanSros1
Copy link

hello
How are you?
so did you solve error?

@JanSros1
Copy link

capture

@daviscabral
Copy link
Collaborator

Hey guys, could you fork the project and make a broken version of the Example app with the same error? That would help me a lot to check it out with the short free time that I have to dedicate to this project lately. Thank you.

@daviscabral
Copy link
Collaborator

Also, not sure if is the same error - so, please, open a new issue, and be sure to put all the possible information to make easier to reproduce this error. Thank you again.

@mightym
Copy link

mightym commented Jun 29, 2018

Same issue here.
"react-native-router-flux": "^4.0.0-beta.31",
All scenes and stacks have a unique key. Btw. I'm encountering this since around beta.18 from time to time. The only way to reproduce it is to do a long time nothing with the app. Happens also on iOS simulator. Wonder if its happening when the app returns from background/sleep sometimes.

bildschirmfoto 2018-06-29 um 19 37 19

@jwilliamson1
Copy link

@shamanking @saurabhabh and anyone else who is having this problem, and is probably also doing Stephen Grider's React-Native course that this example seems to be from. You need to call Actions.pop() or Actions.main(), to go back on instead of using Actions.employeeList({ type: 'reset' });.

try the following if the key is named main:

`export const employeeSave = ({ name, phone, shift, uid }) => {
const { currentUser } = firebase.auth();

return () => {
firebase.database().ref(/users/${currentUser.uid}/employees/${uid})
.set({ name, phone, shift })
.then(() => {
Actions.main();
});
};
};`

or this if you just want to go back one; they both should have the same result:

`export const employeeSave = ({ name, phone, shift, uid }) => {
const { currentUser } = firebase.auth();

return () => {
firebase.database().ref(/users/${currentUser.uid}/employees/${uid})
.set({ name, phone, shift })
.then(() => {
Actions.pop();
});
};
};`

@saurabhabh
Copy link

saurabhabh commented Jul 4, 2018 via email

paullinator added a commit to EdgeApp/edge-react-gui that referenced this issue Mar 4, 2019
This is claimed to be required react-native-router-flex to prevent crashes. Hopefully fixes reported crashes with signature:

"There is no route defined for key"

Reference: aksonov/react-native-router-flux#2439
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