Lane Rettig
Lane Rettig

Reputation: 6958

Live reload in react-native without resetting the route

The live reload feature in react native is neat. But there's one problem. When my app reloads--every time I change the code--the route is reset and it navigates back to the home screen. This is especially annoying if I'm working on a feature that's five or six screens deep. And reloading manually does the same thing.

Is there any way to have it automatically reload the same route it was at before the reload? As a point of comparison, this is not an issue in ionic livereload.

Thanks.

Update: HMR (hot module reloading) shipped with RN 0.22 a few days ago, and this is now possible.

Upvotes: 1

Views: 1403

Answers (1)

rmevans9
rmevans9

Reputation: 5643

This is just the way the live reload works. It reloads all the js and thus you lose all your state. You could probably hack around it by saving state to disk or somewhere else that it will persist across reloads but I would recommend against that. I keep a close eye on commits in the react native repository and there has been a lot of activity around Hot Module Reloading (HMR) which allows components to reload themselves with new js without reloading the entire app. This will give the exact thing you are looking for. I am not sure if this will land in 0.18.0 that is about to release or come out in the next release after that.

Upvotes: 2

Related Questions