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

[Bug]: Error using unstable_HistoryRouter with 6.4.3 #9630

Closed
rlebascle opened this issue Nov 23, 2022 · 6 comments
Closed

[Bug]: Error using unstable_HistoryRouter with 6.4.3 #9630

rlebascle opened this issue Nov 23, 2022 · 6 comments
Labels

Comments

@rlebascle
Copy link

rlebascle commented Nov 23, 2022

What version of React Router are you using?

6.4.3

Steps to Reproduce

"history": "^5.3.0",
"react-router-dom": "6.4.3"

import { unstable_HistoryRouter as HistoryRouter, Routes, Route } from "react-router-dom";
import { createBrowserHistory } from "history";

const history = createBrowserHistory({ window });

<HistoryRouter history={history} basename={basename}>

Expected Behavior

No typing error.

Actual Behavior

TS2741: Property 'encodeLocation' is missing in type 'BrowserHistory' but required in type 'History'.

"encodedLocation" is required in @remix-run/router history but not available in history module.

This is broken since react-router-dom 6.4.3, 6.4.2 is working.

And a quick word to thank you for the amazing work on the data router !

@rlebascle rlebascle added the bug label Nov 23, 2022
@rlebascle rlebascle changed the title [Bug]: [Bug]: Error using unstable_HistoryRouter with 6.4.3 Nov 23, 2022
@rlebascle
Copy link
Author

I found out the change introducing the bug.
#9496

@vishal-kadmos
Copy link

Also observing same issue while upgrading from 6.4.2 to 6.4.3

@vraravam
Copy link

Same issue with us on Ferdium while upgrading from 6.4.2 to 6.4.3 - downgrading till this gets fixed. Thanks for the awesome package btw!

@pleunv
Copy link
Contributor

pleunv commented Nov 28, 2022

This comment might help.

@netcoding87
Copy link

I am facing the same issue, but not with createBrowserHistory, instead I am using createMemoryHistory. The linked post did not help unfortunately :/

@brophdawg11
Copy link
Contributor

There's no functional issue here - this is just a TS error from using an old history@5 implementation with an unstable API in 6.4 which uses a different internal history. These APIs are marked unstable_ because they may encounter breakages like this 😄

The easiest solution is to just add // ts-expect-error since these are incompatible packages:

ReactClient.createRoot(document.getElementById("root")).render(
  // @ts-expect-error
  <unstable_HistoryRouter history={history}>...</unstable_HistoryRouter>
);

Otherwise you can leverage the new history implementation for 6.4+, but note it has some differences from v5 (no blocking, no back/forward - just go)

import { createBrowserHistory } from "@remix-run/router";

const history = createBrowserHistory({ v5Compat: true });

But the recommended solution is to upgrade to RouterProvider as mentioned in #9422 (comment) and #9422 (comment).

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

No branches or pull requests

6 participants