I have a navbar containing 3 Anchors, I want to navigate between different pages when clicking on each one.
I've used react-router (version 6.3.0) to achieve this but I faced two issues and I got a stack.
The first one is when I click on a LaunchApp anchor, the URL change to http://localhost:3000/launchApp the page shows its content but on the top of the home page, not on a new page.
The second one is when I refresh the page, the page doesn't go back to the home page (http://localhost:3000) but it renders the last anchor I clicked on.
App.js
return (
<s.Main>
<>
<Navbar/>
<HeroSection/>
<About/>
<Testimonials/>
<ContactForm/>
<Footer/>
<Routes>
<Route path="/" element={<HeroSection/>}/>
<Route path="/about" element={<About/>}/>
<Route path="/launchApp" element={<LaunchApp />}>
<Route path="submitSubscription"
element={<SubmitSubscription/>}/>
<Route path="CancelSubscription"
element={<CancelSubscription />}/>
</Route>
</Routes>
</>
</s.Main>
);
Navbar return
return (
<nav>
<ul>
<li>
<Link to="/">Home</Link>
</li>
<li>
<Link to="/about">About</Link>
</li>
<li>
<Link to="/launchApp">Launch App</Link>
</li>
</ul>
</nav>
)
Am I missing something?