Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

133
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda