How to prevent react-router from refreshing page?

Viewed 5308

What's the problem?

I am building a project in reactJs with react-router-dom v5. I have added a default route to routing

<Redirect to={"someComponent"}/>

Now the problem is that a simple refresh also redirects me to the default route. How to prevent that?

Code snippet: App.js

return (
      <div className="App">
            <Switch>
               <div id="wrapper" className="main_page">
                 <ErrorBoundary resetState={state}>
                  <Header/>
                    </ErrorBoundary>
                      <div id="page-wrapper" className="mainContentArea">
                        <Route path={`/dashboard/units`} component={Dashboard} />
                          <ErrorBoundary resetState={state}>
                            <Suspense fallback={<div>Loading..</div>}>
                              <Route path={`/dashboard/someRoute`} component={someComponent} />
                            </Suspense>
                          </ErrorBoundary>
                        <Redirect to={"someComponent"}/>
                
                     </div>
                </div>
           </Switch>
      </div>
    );

Can someone help me with the above problem? Due to Redirect in App.js, I am redirected to dashboard even with a simple refresh

Edit:I have Router and BrowserRouter in a separate component.This is just a snippet

1 Answers
Related