Task Description
In this homework assignment, you will implement routing logic for your website using react-router-dom. The task involves setting up the react-router-dom library, creating a layout component, and defining specific routes. Your app should include a LayoutComponent that consistently displays a header and footer, with dynamic content rendered between them. There will be two main routes: AboutPage and ProductsPage. The AboutPage should serve as the index route. Additionally, if an invalid route is accessed, a Page Not Found message should be displayed along with a link redirecting to the AboutPage.
1. Install react-router-dom library:
- Install the
react-router-dom library using npm.
2. Create LayoutComponent:
- Create a
LayoutComponent that includes a static Header and Footer.
- Use the
Outlet component from react-router-dom to render the main content dynamically between the header and footer.
3. Define AboutPage and ProductsPage routes:
- Set up routes for
AboutPage and ProductsPage.
- Ensure that
AboutPage is configured as the index route.
4. Handle invalid routes:
- Implement a
PageNotFound component to display a message for invalid routes.
- Include a link in the
Page Not Found component that redirects users to the AboutPage.
Advance Task Description
(1*)
1. ProductPage Layout:
- Implement the layout for
ProductPage following the provided design specifications.
- Ensure the layout includes all necessary components such as product image, description, price, and any other relevant details.
2. Dynamic Route for ProductPage:
- Add a new route for
ProductPage that includes a dynamic parameter :id.
- Ensure the route is correctly defined in your routing configuration to handle URLs such as
/products/:id.
3. getProduct Request:
- Implement a function
getProduct that fetches product data based on the provided id.
- Ensure the function correctly retrieves and returns the product details from the appropriate data source or API.
- Use the fetched product data to populate the
ProductPage with the relevant information.
Design
For consistent styling and layout, refer to the Figma design you used in the previous task: React Web Page Design.
Acceptance Criteria for 1
Acceptance Criteria for 1*
Task Description
In this homework assignment, you will implement routing logic for your website using
react-router-dom. The task involves setting up thereact-router-domlibrary, creating a layout component, and defining specific routes. Your app should include aLayoutComponentthat consistently displays aheaderandfooter, withdynamic contentrendered between them. There will be two main routes:AboutPageandProductsPage. TheAboutPageshould serve as theindexroute. Additionally, if an invalid route is accessed, aPage Not Foundmessage should be displayed along with a link redirecting to theAboutPage.1. Install
react-router-domlibrary:react-router-domlibrary usingnpm.2. Create
LayoutComponent:LayoutComponentthat includes a staticHeaderandFooter.Outletcomponent fromreact-router-domto render the main content dynamically between the header and footer.3. Define
AboutPageandProductsPageroutes:AboutPageandProductsPage.AboutPageis configured as theindexroute.4. Handle invalid routes:
PageNotFoundcomponent to display a message for invalid routes.Page Not Foundcomponent that redirects users to theAboutPage.Advance Task Description
(1*)
1.
ProductPageLayout:ProductPagefollowing the provided design specifications.2. Dynamic Route for
ProductPage:ProductPagethat includes a dynamic parameter:id./products/:id.3.
getProductRequest:getProductthat fetches product data based on the providedid.ProductPagewith the relevant information.Design
For consistent styling and layout, refer to the Figma design you used in the previous task: React Web Page Design.
Acceptance Criteria for
1LayoutComponentwith a staticheaderandfooter, and anOutletfor dynamic content, is added.AboutPageandProductsPage, are added.AboutPageis set as theindexroute.Page not foundwith a link to theAboutPage.Acceptance Criteria for
1*ProductPageis added according to the design.ProductPagewith dynamic parameters:idis added.getProductis implemented, using the product'sid.