jmurzy / react-router-native

A routing library for React Native that strives for sensible API parity with react-router 🤖
MIT License
637 stars 44 forks source link

Handling modals #49

Open jeanregisser opened 7 years ago

jeanregisser commented 7 years ago

For of all, thank you for creating this library and experimenting with it. I really like the stated goals. I've been dreaming of having easy deep linking in a native app for a long time ;)

Now, I'm trying to see how to handle modal screens (fullscreen or popups).

So far I've tried the following:

<Router history={nativeHistory}>
  <StackRoute path="master" component={Master}>
    <StackRoute path="master2" component={Master}>
      <Route path="/" component={Home} overlayComponent={HomeHeader} />
      <Route path="/detail/:themeColor" component={Detail} overlayComponent={DetailHeader} />
    </StackRoute>
    <Route
      path="/modal"
      component={Modal}
      transition="vertical-card-stack"
    />
  </StackRoute>
</Router>

It works partially:

Also there's a warning displayed that says <TabsRoute> and <StackRoute> cannot be nested within <StackRoute>. So I know this wasn't intended to be done like this ;)

Is there another way to handle this?

jeanregisser commented 7 years ago

I've also tried this:

<Router history={nativeHistory}>
  <StackRoute path="master" component={Master}>
    <Route path="/" component={Home} overlayComponent={HomeHeader} />
    <Route path="/detail/:themeColor" component={Detail} overlayComponent={DetailHeader} />
    <StackRoute
      path="master2"
      component={Master}
      transition="vertical-card-stack"
    >
      <Route path="/modal" component={Modal} overlayComponent={HomeHeader} />
    </StackRoute>
  </StackRoute>
</Router>

The main problem is the animation which directly hides the nav bar of the initial stack. And of course I still have the warning about nested <StackRoute>.

frimoldi commented 7 years ago

Hey, I'm getting the same warning for nested <StackRoute>s. Did you solve this ?