After updating a react native app, trigger an action before app launch (clean persistent store in my case) - react-native

I modified some redux store (using redux-persist) logic in my app, and when a user update the app, at the first launch he get a crash because of inconsistency between the previous store and my new code. If the user relaunch the app everything is fine.
How can i detect that this is the first launch of an updated app version, clean the store and then render the app with new store initialization ?
I know how to clean the store, the part i struggle with is the way to know if the app just got updated and it's the very first launch. I don't want to clean at every launch.
Thanks in advance

Related

Fast Refresh in production mode - React Native

i am new to react native. i already build mobile apps which take configuration from ENV file. i use Config from react-native-config. but now i want to change value of some property in that Config file.
I managed to call hook and get data. let's say the data is "X" and i success to store "X" in "Config.name". but nothing change in my app. i had to do fast refresh in order to see the changing.
my question is, is it possible to do fast refresh in production mode? if not, how can i work around with this? i have to call hook in order to get the data first so i think it was the problem since i couldn't call hook when the app in prebuilt. so the app took value from ENV file instead of waiting from hook call.

is it possible to replace existing react native app with a new one?

I have a react native project on 0. 59 version and I tried to do major updates to 0. 60. But it seems to be impossible I can not run the app on the emulator. So I had this idea of creating an empty project and to transfer my code on it. Has someone ever done something like this?
Is there a way to link existing app on the app store with a new
Yes, you can start a complete new app and replace it in the App Store with the new one.
The app is only identified by the bundle identifier (iOS) or the applicationId (android).
But I would recommend using upgrade helper before migrating to a new project.

React-native redux navigation state reset after crash

We are using redux navigation and persisting redux state. However, sometimes when the user navigates to the page and an unexpected error occurs app crashes with a white screen. If the app is launched again it obviously crashes again because the same state is loaded. As the result app becomes unusable - the white screen crash straight after the app launches.
I guess it is fine to crash the app if there is a bug on one of the screens, but because of one buggy screen I don't want to make the entire app unusable for a user and it would be great to somehow reset a state and enable the user to keep using other functionality of the app.
Any ideas on how to achieve that?
I think the real question is: do you want to persist navigation state at all? Do you really want to load last visited screen on app launch rather than the first screen of the app? I've never seen an app that does this
Another question is how do you persist your navigation state in redux. It was only a pattern when using older versions of react-navigation (v1 and v2 if I recall correctly) but even then it wasn't the optimal pattern to keep navigation state in redux (redux integration of react-navigation v1), let alone persist it on restarts. Navigation is something that should start fresh every time user launches the app
Also read about state persistence in current version (v5 - https://reactnavigation.org/docs/state-persistence) usually there is no redux involved at all
About state persistence: usually you only persist long-living things like auth state, authorization tokens, user settings, but not some dynamic data that gets discarded often. For example, if you open some page and fetch data to display on that page, there is no reason to persist that data in AsyncStorage, because why would you? This data should be reloaded every time page opens instead of restored from persisted state. Redux-persist lets you whitelist or blacklist different parts of the state
To summarize:
1. figure out if you need to persist navigation state at all. If not, problem solved
2. if you do, try to setup redux-persist the way that it doesn't persist short-living error-prone data
3. figure out how navigation state is persisted (through redux or on it's own, see examples in the links I provided earlier)
4. integrate react-native-exception-handler, catch exceptions and reset persisted navigation state in case of a crash

How to intercept event of dev reload on React Native?

How can I intercept the reloading process on Android (Dev menu -> Reload)?
I want to clear some part of Redux store when is happend the action.
The question provides quite a little insight but seeing that some working is required on the redux store every time there is a reload, you can catch INIT action fired by Redux every time the store is initialised, IMO

How can i change the background of my App after it approved and already in App Store

I am new in Xcode and IOS development.
i have designed and finished my app and i connected with Parse for push notification and core data.
the problem is what i didn't understand is: if in future i want to change the background of my app or add new event or to change the palace of button my app, how can i do that? i have to rebuild and submit it again or there is any way to do by online a website like parse?
i couldn't find the answer any where, help please...
Thanks ,
If you had designed your app to load the background data from Parse, then you could just put the new background on Parse and your app would load it. There is no need to submit a new app to do that. If you did it this way, you'd want to have a default background in the case when the network is not available.
You can't add new code to your application with this method (that is not allowed), but you can add data such as images, text, etc. The key point here is that you have to design your app from the start to work this way, then it is simply a matter of putting the new data on Parse where your app can find it.
Expanding on #vacawama's very good answer:
For this version you are out of luck, since it sounds like you did not design it to use a background that is loaded from your Parse server.
What you need to do is to code an update to your app that has these new abilities, and submit that to the app store. Once that version is approved then you should be able to change the background from the server.