Next-routes: Problem with router event handlers

Created on 25 Oct 2017  路  3Comments  路  Source: fridays/next-routes

By using this router, handlers like onRouteChangeStart will not work.

Most helpful comment

@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>
);

All 3 comments

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>
);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

JiiB picture JiiB  路  4Comments

breeny picture breeny  路  5Comments

jchiellini picture jchiellini  路  4Comments

mocheng picture mocheng  路  5Comments

jesstelford picture jesstelford  路  3Comments