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

256
Vistas
Can you render react component to div with display none?

I need to render react component to div with id hover-countdown. So as the name says it is not visible when page load, but only on hover. Does this somehow affect ReactDOM render? Because i am not able to render it. Is there some other way? Thank you:)

const HoverCountdown = () => {

  return (
    <span>Countdown</span>
  );
};

document.addEventListener("DOMContentLoaded", () => {
  ReactDOM.render(
    <HoverCountdown />,
    document.getElementById("hover-countdown")
  );
});
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Does this somehow affect ReactDOM render?

Not really. It React only concerns itself with DOM updates.

If the element it renders inside is display: none then the React rendering process will generate the DOM inside that element.

Then, subsequent to the React rendering, the browser will convert the DOM to something rendered on screen (which will be nothing because the container is display: none).

about 4 years ago · Juan Pablo Isaza Denunciar

0

If you set the visibility to hidden, hovering over the invisible component will not trigger the :hover styles to take effect.

What is odd is that if you inspect element and toggle the :hidden styles then it will properly show up.

const HoverCountdown = () => (
  <span>Countdown</span>
);

//document.addEventListener('DOMContentLoaded', () => {
  ReactDOM.render(
    <HoverCountdown />,
    document.getElementById('hover-countdown')
  );
//});
.wrapper {
  background: #EFE;
}

#hover-countdown {
  visibility: hidden; /* will render fine if removed */
}

#hover-countdown:hover {
  visibility: visible;
  color: #040;
  cursor: pointer;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.1/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.1/umd/react-dom.production.min.js"></script>
<div class="wrapper">
  <div id="hover-countdown"></div>
</div>

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