The story for this project is that we store information about popular programming languages in a MongoDB instance, and we can vote on the languages using React UI.
In this section, you'll improve the React-created UI by focusing on the implementation of client-side routing with React.
cd backend
npm installcd frontend
npm install- Set your MongoDB URL in the
./backend/config/.envfile.
You can find sample setting in./backend/config/.env.samplefile. - Run
node backend/db/populate.js- alternatively you can usenpm run populatescript.
cd backend
npm run devStartcd frontend
npm run devIf you have successfully completed all the above points, the page will load without errors but with empty content. Next, we will work on getting the functionality of the page up and running. To do this, you need to go through the listed tasks. In the ./frontend/src directory, find a file with a comment matching the task point, for example, TASK 1 and implement the requested functionality.
Implement the BrowserRouter component!
Implement the Routes component within the previously implemented BrowserRouter!
Implement a Route for the Layout component, which should be visible when the main page ("/") is loaded!
Implement (child) routes for the following components, each associated with the following paths:
Main - "/"
About - "/about"
Demo - "/demo"
LanguageCreator - "/language-creator"
LanguageDetails - "/languages/:langid"
Implement an error route that loads when the address is nonexistent!
If you try the functionality of the page now, it won't work correctly because an Outlet component is missing from the Layout component. Implement this!
Implement Link components around the buttons in the Layout! This way, we can achieve that clicking on a particular button updates the browser's address bar with the corresponding path and loads the respective component under the Layout component.
Again, implement a link component around the Show details button! When the user clicks on it, the browser's address bar should display the following path: /languages/langid, where langid is the id of the respective language.
In the LanguageDetails component, we need information about which programming language details to load. To retrieve this, use the useParams React hook!
In the ErrorPage component, implement a button with the label Go to the splash page. When the user clicks on it, it should navigate to the main page. Use the useNavigate React hook to achieve this solution!