A react app using hooks. In useEffect
there is an api-call to populate content on page.
Each element fetched is clickable. And a click will open details for the clicked element in a new browser window/tab.
When working in the new window, the user can make changes on that object. The user will then close that tab or at least just go back to the main window/tab.
Question is how I can detect that the user is coming back to the main window. This is because I want to re-fetch data from API. Thus, I want to rerun useEffect
.
While googling I found this:
https://www.npmjs.com/package/react-page-visibility
Is that really what I'm looking for? Reading the docs I'm not really sure if that can be the solution to my issue. Is there another way to solve this?
question from:
https://stackoverflow.com/questions/65647295/how-to-rerun-useeffect-when-page-is-visible 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…