score:1

Accepted answer

Change

export default class OwnBrowserRouter extends BrowserRouter {
  history
}

To

export default class OwnBrowserRouter extends BrowserRouter {
  history = history;
}

As stated in the Class fields proposal, certain transpilers may ignore the field completely. Thus the original history (the one created in the original BrowserRouter) will be used.

Both public and private field declarations create a field in the instance, whether or not there's an initializer present. If there's no initializer, the field is set to undefined. This differs a bit from certain transpiler implementations, which would just entirely ignore a field declaration which has no initializer.


Related Query

More Query from same tag