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

131
Vistas
Should I create new component or render js conditionaly?

I have a case where I need to render one react component again in a different place. So, for example, I have an index component where I have a list of users and filters for this list. Now I need to render this component in a different place but without filters. Should I create a new almost the same index component and skip rendering filters or should I pass prop and render conditional JSX?


const Index = ({ renderFilters }) => {
  ... some code
  return (
    <>
      ...some jsx code
      { renderFilters ? <Filters /> : null }
      <UserList>
      ...some jsx code
    </>
  )
}

or just copy-paste the index component and


const IndexWithouFilters = () => {
  ... some code
  return (
    <>
      ...some jsx code
      <UserList>
      ...some jsx code
    </>
  )
}

Of course, this is only an example and I have a case where have to render conditionally more than one components.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It is a best practice in Reactjs to reuse components.So go with former approach.

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