I'm using React Router to manage the URLs of my webapp. This is what I have so far in Routes.js:
const Routes = () => {
return (
<React.Fragment>
<Navbar />
<Switch>
<Route exact path="/inicio" component={Home} />
<Route path="/productos" component={Products} />
<Route path="/la-empresa" component={LaEmpresa} />
<Route path="/contacto" component={Contact} />
<Route path="/servicios" component={Servicios} />
<Route path="/prensa" component={Prensa} />
</Switch>
<WhatsappBtn />
<Footer />
</React.Fragment>
);
};
As you can see, I'm rendering the navbar, footer and a whatsapp floating button in every page, and inside those goes the content. I thought that this was awesome, since I'm not loading those three every time the user goes to a different page, but I'm coming across this issue: When I visit a URL that does not correspond to any of the paths, I get those components anyways (which makes sense). I would like to display a 404 page instead.
How is this possible whithout sacrificing the performance?