Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v6] Support history prop on <BrowserRouter /> #7585

Closed
salvoravida opened this issue Aug 26, 2020 · 3 comments
Closed

[v6] Support history prop on <BrowserRouter /> #7585

salvoravida opened this issue Aug 26, 2020 · 3 comments

Comments

@salvoravida
Copy link
Contributor

Hi guys, great work with v6 release!

Just a little note:

It would be nice to add support for a already created history object on <BrowserRouter
and skip creation if it is passed as prop.

We need it to support redux-first-history integration.

Can i open a PR about it?

Regards,

@timdorr
Copy link
Member

timdorr commented Aug 26, 2020

You would need to implement your own Router component in the new system. <Router> no longer takes a history prop, so it's not as simple as just passing it through:

https://github.com/ReactTraining/react-router/blob/761f104ed144601b3bcd7a8a35aa635afc5e05db/packages/react-router-dom/index.tsx#L92-L117

@timdorr timdorr closed this as completed Aug 26, 2020
@salvoravida
Copy link
Contributor Author

salvoravida commented Aug 26, 2020

Yes i have already seen beta0 code

I suppose to add history suport on <BrowserRouter not <Router, just small change:

 export function BrowserRouter({ children, history, window }: BrowserRouterProps) { 
   let historyRef = React.useRef<BrowserHistory>(); 
   if (historyRef.current == null) { 
     historyRef.current = history || createBrowserHistory({ window }); 
   } 

Isn't it possible? @timdorr

@timdorr
Copy link
Member

timdorr commented Aug 26, 2020

Yeah, that should be fine. You can always open up a PR, no need to ask.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants