Arpith Siromoney 💬

More Navigation in React Native

Using Navigator’s immediatelyResetRouteStack()

I’m building an app (Constellational) to post notes online, and one thing I’ve wanted is to go to the Edit Page after you sign in — this is so that you can get straight down to the business of writing a note. 

To do this, I’m using React Native’s immediatelyResetRouteStack():

getStarted() {
   {id: 'navigation'},
   {id: 'posts'},
   {id: 'edit'}

This class method gets called once a user is signed in (and taps the ‘Get Started’ button). What it does is pass an array of routes — in our case, objects with ids will do — to the Navigator’s immediatelyResetRouteStack() method.

This means that once you’re signed in you will end up in the Edit Page where the cancel button (which pops on the Navigator) will take you to the Posts Page, whose back button will then take you to the Navigation Page. That’s as simple as it gets!

Sounds interesting? Want a home for your notes online? Sign up here.