Can not use history v5 with RRD v6, TS error Type 'BrowserHistory' is missing the following properties from type 'History': createURL, encodeLocation

264 views Asked by At

I'm currently using React Router DOM v 6.8.1 and history v 5.3.0 I just followed this example

But I get a TS error when trying to use history to HistoryRouter

<HistoryRouter history={history}>
   // code 
</HistoryRouter>

Type 'BrowserHistory' is missing the following properties from type 'History': createURL, encodeLocationts(2739)

enter image description here

Here is an example on codesandbox

1

There are 1 answers

1
Shibin Raja On

Change the react-router-dom version to 6.3.0 and it should work. Else use a custom-made router function. Refer to the Screenshot how to use a history in react-router-dom

enter image description here