How to use the next/router.router function in next

To help you get started, we’ve selected a few next examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github charliewilco / downwrite / client / utils / mock-next-router.tsx View on Github external
return foo;
  },
  events: {
    on: (eventName: EventName, handler?: EventHandler | ErrorEventHandler) => {
      // let foo: void;
      // return foo;
    },
    off: (eventName: EventName, handler?: EventHandler | ErrorEventHandler) => {
      // let foo: void;
      // return foo;
    }
  }
};

// @ts-ignore
Router.router = mockRouter as RouterProps;

// https://github.com/zeit/next.js/issues/5205#issuecomment-422846339
export default class MockNextContext extends React.Component {
  static childContextTypes = {
    headManager: PropTypes.object,
    router: PropTypes.object
  };

  getChildContext() {
    const { headManager, router } = this.props;
    return {
      headManager: {
        updateHead() {},
        ...headManager
      },
      router: Object.assign(mockRouter, router)
github dpla / dpla-frontend / components / shared / GaWrapper.js View on Github external
componentWillUnmount() {
      Router.router.events.off("routeChangeComplete", this.trackPageview);
    }
github dpla / dpla-frontend / components / ExhibitionsComponents / ExhibitionSection / GaExhibitWrapper.js View on Github external
componentWillUnmount() {
      Router.router.events.off("routeChangeComplete", this.trackPageview);
    }
github dpla / dpla-frontend / components / PrimarySourceSetsComponents / Source / components / ContentAndMetadata / GaPssWrapper.js View on Github external
componentDidMount() {
      initGa();
      this.trackSourceView();
      Router.router.events.on("routeChangeComplete", this.trackSourceView);
    }
github zapkub / cu-vivid-museum-wiki / legacy / containers / SearchInputBar.js View on Github external
withState('texts', 'onTextChange', () => {
         if (!Router.router) return ''
         const { query } = Router.router
         if (!query.searchTexts) {
           return ''
         }
         return query.searchTexts
       }),
       graphql(gql`
github zooniverse / front-end-monorepo / packages / app-project / src / screens / ProjectHomePage / components / Hero / Hero.stories.js View on Github external
router: { ...mockedRouter, ...mockRouter }
      }
    }
    render () {
      return this.props.children
    }
  }

  MockRouterContext.childContextTypes = {
    router: PropTypes.object
  }

  return MockRouterContext
}

Router.router = mockedRouter

const StorybookRouterFix = withMockRouterContext(mockedRouter)

function MockProjectContext({ children, theme }) {
  return (
    
      
        
          
            {children}
          
        
      
    
  )
}
github quietshu / vrs / public / components / Layout.js View on Github external
componentDidMount() {
    this.sbs = ScrollBar.initAll()
    if (window.scrollHandlers) {
      window.scrollHandlers.forEach(handler => {
        this.sbs[0].addListener(handler)
      })
    }
    this.route = Router.router ? Router.router.pathname : ''
    this.forceUpdate()
  }