Closed arefaslani closed 7 years ago
Pardon me, That was just a mistake.
Sorry to bring this up again - but what was your mistake? next/router events aren't firing for me at the moment so perhaps I'm doing the same thing?
Thanks!
@nickyhajal Sorry but I don't remember what was my problem. But this is a simple component that uses routes events that may help:
import React from "react";
import Head from "next/head";
import NProgress from "nprogress";
import { Router } from "routes";
NProgress.configure({ showSpinner: false });
Router.onRouteChangeStart = url => {
NProgress.start();
};
Router.onRouteChangeComplete = () => NProgress.done();
Router.onRouteChangeError = () => NProgress.done();
export default () => (
<div style={{ marginBottom: 20 }}>
<Head>
{/* Import CSS for nprogress */}
<link rel="stylesheet" type="text/css" href="/static/css/nprogress.css" />
</Head>
</div>
);
By using this router, handlers like
onRouteChangeStart
will not work.