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

davetgreen picture davetgreen  路  3Comments

yormi picture yormi  路  3Comments

stnwk picture stnwk  路  3Comments

imWildCat picture imWildCat  路  3Comments

alexyaseen picture alexyaseen  路  3Comments