I implemented a loading screen using a loader component on _app.js
function MyApp({ Component, pageProps }) {
const [loading, setLoading] = useState(false)
Router.events.on('routeChangeStart', (url) => {
setLoading(true)
})
Router.events.on('routeChangeComplete', (url) => {
setLoading(false)
})
return(
<>
..<Head> <meta> tags here..
{loading && <Loader />}
<Component {...pageProps} />;
</>
)
}
The problem is, although the loader component <Loader/> appears, when I scroll down, the page's content represented by <Component {...pageProps} />; can still be seen. This would break the purpose of the loader component. I'm supposed to only see the loader component while the page is still rendering.