How to check if page is refreshed in React js?

Solution To check if the page is refreshed in react js, use the window.performance.navigation method if it will contain reload navigation entries it means the page is refreshed. window.performance.navigation The navigation read-only property of the Window interface returns the current window’s associated Navigation object. Snippet In this snippet, we will note important parts checking reloaded pages. const pageAccessedByReload = ( (window.performance.navigation && window.performance.navigation.type === 1) || window.performance .getEntriesByType('navigation') .map((nav) => nav....

November 29, 2022 · 1 min · The Unknown Developer