DEV Community

abdelrahman El Hoseeny
abdelrahman El Hoseeny

Posted on

What will we lose if we use regular link instead of React routing in SPA

Alt Text

According some requirements from client to replace routing with real links, as we work Single Page Application there are some features we will lose :

1- Shared UI Components :

Routing in react is like show and hide some components without reload page so the only part that loaded is the new part only using (virtual Dom), so the transforming between components smooth and easy.
If we use real links instead, the application will reload again every time we click on the link even we are still in the same page and nothing changed.

2- Shared data by using state and state management:

In single page application one of the main concepts is to share data with all components that will use it, so we load it one time and use it many times.
If we use real links we will need to reload the same data many times to use it.

3- Authorization process

Every time we access any page the application will call again all services that need to call to manage this page although it is called before among of this connecting with Keycloak to get new token even the first not expired

Some references about that :

https://reacttraining.com/blog/reach-react-router-future/
https://www.pluralsight.com/guides/understanding-links-in-reactjs
https://www.quora.com/What-is-the-difference-between-the-href-and-routerLink
https://reactjs.org/docs/faq-internals.html
https://stackoverflow.com/questions/23975199/when-to-use-client-side-routing-or-server-side-routing

Top comments (0)