I am developing a React Native app that incorporates a React application via react-native-webview. My goal is to synchronize changes made to the language key in the web view’s local storage with the async storage in my React Native app.
Here’s the current setup:
- React Native App: This is the main application.
- React App: Runs inside a react-native-webview in the React Native app.
I need to detect whenever the language key in the web view’s local storage changes, and subsequently update the async storage in the React Native app accordingly.
I attempted to periodically check for changes in the local storage by setting up intervals within the React native app (with injected JS). This approach does successfully detect changes, but I am aware that using intervals is not efficient or the most effective method for this purpose. I am looking for a more optimal approach.
Ido Aviram is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.