Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

127
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda