Part 1: Reconfiguring the App
Setup and Getting Started
- Accept the assignment on GitHub Classroom.
- Clone the repository to your local machine.
- You will find it already setup with the Rock Paper Scissors Game.
- Install the dependencies by running
npm install. - Start the development server by running
npm run dev.
Housekeeping
- Create a new folder for the different pages of the app.
- You can call it
pages,routes,views, or anything else you prefer and makes sense.
- You can call it
- Move the game components to a
rpsfolder, then move that folder to the new folder.
Create a Home Page Component
- Create a new file
HomePage.jsin theroutesfolder. - Create a functional component
HomePagein theHomePage.jsfile.- For now, it can just be a simple heading and a paragraph.
- Feel free to get fancy and creative with the content.
Create a Navigation Component
- Create a new folder for the different components of the app.
- You can call it
components,common,shared, or anything else you prefer and makes sense.
- You can call it
- Create a new file
Navigation.jsin thecomponentsfolder. - This components will serve as the navigation bar for the app.
- To start, this can just be a simple unordered list with a few list items.
- Each list item will be a link to a different page of the app.
- For now, you can just have a link to the home page.
Install and Setup React Router
- Install the
react-router-dompackage by runningnpm install react-router-dom. - In the
main.jsfile, you can replace theAppcomponent with a<RouterProvider>component. - In the
RouterProvidercomponent, you'll need to provide the routes. - You'll need to use the
createBrowserRouterfunction fromreact-router-domto define the routes. - Setup the routes for the home page and the rock-paper-scissors game.
Update the Navigation Component
- Update the
Navigationcomponent to use theLinkcomponent fromreact-router-dom. - The links should point to the home page and the rock-paper-scissors game.