pennapps / pennapps.com

The PennApps Main Website
https://pennapps.com
1 stars 0 forks source link

Refactor pages into reusable components #25

Closed MechaJoe closed 1 year ago

MechaJoe commented 2 years ago

Currently, there are 3 React components pertaining to the FAQ section on pennapps.com:

  1. FAQSection.js - A single question and answer component, that opens and closes using the Collapse component
  2. FAQs.js - A group of FAQSection.js components, which comprises an entire FAQ portion of a page
  3. ApplicationsFAQs.js - A component that uses FAQSection.js instead of FAQs.js to be included in the Organizers page

The problem is that ApplicationsFAQs.js contains duplicated logic--it reimplements the FAQs.js component using FAQSection.js only, when it could use an FAQs.js component and pass in the right content instead.

Because React's greatest strength is that it is modular, and this situation is a good example of when to abide by DRY principles we would like the Organizers page to use FAQs.js instead of ApplicationsFAQs.js.

To start, see lines 6-16 of FAQs.js, 14-24 of ApplicationsFAQs, and line 50 of organizers.js. As a hint, you'll need to replace the use of map() in ApplicationsFAQs with the FAQs.js component. The goal is to be able to delete ApplicationsFAQs.js for it not being in use once we're done here!

Some resources: