React-router: BrowserRouter accepts history object

Created on 13 Mar 2017  路  2Comments  路  Source: ReactTraining/react-router

Usa case: Google Analytics + React Router.

  • I want to use history.listen object to send data to GA outside of my components structure.
  • Then I want to pass this history object to BrowserRouter so routes will use that history intance.

<BrowserRouter history={history}> </BrowserRouter>

Most helpful comment

Just use <Router> directly. <BrowserRouter> is just a wrapper with a pre-built history, so you can do the same with custom history instance.

All 2 comments

Just use <Router> directly. <BrowserRouter> is just a wrapper with a pre-built history, so you can do the same with custom history instance.

Yes, perfect. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maier-stefan picture maier-stefan  路  3Comments

wzup picture wzup  路  3Comments

sarbbottam picture sarbbottam  路  3Comments

ryansobol picture ryansobol  路  3Comments

misterwilliam picture misterwilliam  路  3Comments