Is there a generic event I can attach a listener to in a React web application, which is triggered when the browser application is brought from background to foreground?
For instance, here is a use case:
- I hold the mobile device in portrait orientation with the browser app in foreground
- I load the web application
- I send the browser app to the background (i.e., go to the home page or switch to another app)
- I change the mobile device orientation to landscape
- I bring the browser app into foreground
- An event is triggered in the web application to perform an action (e.g., re-render the page)
Using the visibilitychange event does not appear to work (e.g., iOS Chrome):
componentDidMount() {
/* ... */
window.addEventListener("visibilitychange", function() {
/* do work... */
});
/* ... */
}
Is there another event I can listen for, when the browser app's foreground state changes?