Difference between how react-router works and how href tag works?

Viewed 64

What is the difference between how react-router works and just tag works?

I know there is a way I can use href tag in react but I saw most of the times people use react-router instead.

And I also found that in next.js which is a framework of react.js, href is frequently used.

Is this something to do with client-side-rendering and server-side-rendering?

1 Answers

What is the difference between how react-router works and just tag works?

React router loads your component without reloading the page ,it just manipulates the DOM.

Is this something to do with client-side-rendering and server-side-rendering?

Yes,when your page refreshes ,most of the time you are getting something from server.

An example demo-https://codesandbox.io/s/react-router-basic-4753w?fontsize=14

You will see the last href refreshes the page ,rest others Donot ,they just change the DOM

Related