Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Example of React Router V4 usage: #122

@stunningpixels

Description

@stunningpixels

Spent a while trying to figure this out, might be useful for someone...

To hook onto page changes with Router V4 - listen to the history rather than trying to do onUpdate on the Router element:

import Home from '../Home'
import About from '../About' 
import createHistory from 'history/createBrowserHistory'
import { Router, Route } from 'react-router-dom'

const history = createHistory()
history.listen((location, action) => {
  ReactGA.set({ page: location.pathname });
  ReactGA.pageview(location.pathname);
});

<Router history={history}>
    <Route exact path="/" component={Home}/>
    <Route exact path="/about" component={About}/>
</Router>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions