How we save 1M hours of development using React Navigation

Sibelius Seraphini
Feb 21, 2019 · 2 min read

React Navigation is the facto solution when you talk about navigation in React Native app. React Navigation 3.x has many improvements in performance and code that your apps just benefits from it.

When doing development on web, when you reload a page you go back to the same page you were at, because the browser has the url, and url is the state of your navigation on web.

However on react native app we don't have an url to save our navigation state, and every time you reload your app, you going to start at the initial route of your navigation, this takes you a lot of time because you need to go back to the navigation state you were at. You were just waiting your time navigating back at every reload. So how can we fix this?


Navigation State Persistence to rescue

React Navigation has an experimental feature that let you persist your navigation state to AsyncStorage, so every time you reload your app you are going to be in the same screen you were at, isn't beautiful?

You can read more here in the docs https://reactnavigation.org/docs/en/state-persistence.html


Adding to your React Native App (latest version)

Adding to your React Native App (old version)

You just need 2 lines to make this work in your React Native App

This 2 lines will save many hours of development, kudos to reactnavigation team

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store