0

The problem is that there are 3 components through which i need to route through without changing the URL but also there are components that do change the routes.

So I am nesting the MemoryRouter inside the BrowserRouter but when I get inside the MemoryRouter there is no coming out.

I have tried this:-

   const history=createBrowserHistory();
    window.browserHistory=history;
    <BrowserRouter history={history}>   
    <Switch>
      <Route path="/quotes" component={QuotePage} />
      <Route exact path="/" component={GreetingPage} />
    </Switch>
    </BrowserRouter>

Inside the MemoryRouter i have something like this.

<MemoryRouter>
  <Switch>
    <Route exact path="/" component={Form1} />
    <Route path="/form2" component={Form2} />
  </Switch>
<MemoryRouter>

In Form 2 I have a function that calls

window.browserHistory.push("/quotes");

Now "/quotes" is visible in the link but the component is not loading.

1 Answers1

0

Use a html a tag instead of react-router Link component in order to get out of MemoryRouter.

Farhad
  • 3
  • 3