Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
What would be the best way to refactor this React component and keep it DRY?

I have been trying to refactor this React component and thinking of ways to keep it DRY (don't repeat yourself). So what would be the best way to refactor this React component and keep it DRY?

Here is the codesandbox

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Why do you think the component is not DRY? If your components like ScheduleTimeTextSpan are styled-components (which is my assumption) then they are just HTML elements with prefilled styles so it is okay to repeat them. The only thing that might help you DRY a little bit the component might be refactoring the code sections like:

<ScheduleTimeText>
 Appointment due:
 <ScheduleTimeTextSpan>
   {content.appointmentDue}
 </ScheduleTimeTextSpan>
</ScheduleTimeText>

which are repeated, to a self component:

const AppointmentDue = ({content}) => (
   <ScheduleTimeText>
     Appointment due:
     <ScheduleTimeTextSpan>
       {content.appointmentDue}
     </ScheduleTimeTextSpan>
   </ScheduleTimeText>
)

and then calling: <AppointmentDue content={content} />

This will save some lines of text.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!