piwik-react-router icon indicating copy to clipboard operation
piwik-react-router copied to clipboard

react-router-dom

Open ujjalacharya opened this issue 6 years ago • 4 comments
trafficstars

does it support react-router-dom@5+

ujjalacharya avatar Nov 05 '19 09:11 ujjalacharya

Yes, I have this working

jonfreedman avatar Jan 02 '20 16:01 jonfreedman

@jonfreedman Hey, could you give any example how to get this work with BrowserRouter?

borysfranc avatar Jan 23 '20 11:01 borysfranc

See https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/Router.md#router

You need to replace BrowserRouter with Router and call createBrowserHistory() e.g

const history = createBrowserHistory();
const matomo = PiwikReactRouter({
    clientTrackerName: 'matomo.js',
    serverTrackerName: 'matomo.php',
    siteId: matomoSiteId,
    url: matomoUrl
});
return (
    <Router history={matomo.connectToHistory(history)}>
        <YourApp />
    </Router>
);

jonfreedman avatar Jan 27 '20 11:01 jonfreedman

@jonfreedman Thanks a lot for your answer ! I managed to get the same solution, but thanks again for your response :)

borysfranc avatar Jan 27 '20 12:01 borysfranc