Skip to content

Extra Scene needed when using react-native-drawer with Actions.create() #1690

Closed
@Dennitz

Description

@Dennitz

Version

Tell us which versions you are using:

  • react-native-router-flux v3.38.0
  • react-native v0.41.2

Expected behaviour

When creating all scenes directly as children of Router, it is enough to have the drawer scene as the root scene, i.e.

<Router>
  <Scene key="drawer" component={NavigationDrawer} open={false}>
    <Scene key="requiredBecauseOfDrawer">
      <Scene key="scene1" component={Scene1} />
      <Scene key="scene2" component={Scene2} />
    </Scene>
  </Scene>
</Router>

So when creating the scenes with Actions.create() I think it should be the same:

const scenes = Actions.create(
  <Scene key="drawer" component={NavigationDrawer} open={false}>
    <Scene key="requiredBecauseOfDrawer">
      <Scene key="scene1" component={Scene1} />
      <Scene key="scene2" component={Scene2} />
    </Scene>
  </Scene>
)

and then:
<Router scenes={scenes} />

Actual behaviour

When my scenes are defined using Actions.create() and I then click a button to open the drawer, i get the error: 'No parent is defined for route=drawer'.

It works again when I add another surrounding scene, like this:

const scenes = Actions.create(
  <Scene key="root">
    <Scene key="drawer" component={NavigationDrawer} open={false}>
      <Scene key="requiredBecauseOfDrawer">
        <Scene key="scene1" component={Scene1} />
        <Scene key="scene2" component={Scene2} />
      </Scene>
    </Scene>
  </Scene>
)

Steps to Reproduce

  1. Define scenes using Actions.create() with drawer scene as the top level scene
  2. Click button that calls Actions.refresh({ key: 'drawer', open: true })

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions