![]() ![]() Now delete the previously written code and let's write it from the scratch. Open the project in your editor or IDE of your choice and open app.js from the src folder. Now you can run the app using the below command.Īfter a while, you can see the browser popping up and showing a site at localhost:3000 Now it's time to install the react-router-dom NPM package into the project. Now navigate into the folder using the below command. Now, you will see a new folder created and inside the file, you can see something similar to this. ![]() Run the command below in your command prompt/terminal/git bash. The core package for the router is react-router, whereas the other two are environment. ![]() Let's now start by creating a react project and use react-router in that.įirstly create a new react application and call it routerapp. The React Router library comprises three packages: react-router, react-router-dom, and react-router-native. So, I hope now you know why we use react-router. Simply, You don’t need to refresh the whole page when you click on any link.Īs the page won't reload so how to change pages? So, here comes react-router which is used to move between different pages of the application without refreshing the page. It re-renders its content in response to actions without refreshing the page. React is a JavaScript framework that is used to make SPAs (Single Page Application). Before learning about React Router let's see whats react and why we need to use react-router? ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |