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

109
Vistas
Rendering null in react element prevents me from using css's :empty selector

To better explain my question, I'll use an example:

Let's say I have two react elements, which contain one another. Lets call the container Box, and the child Stuff. Box just renders a div with className="box" which surrounds the children it is given. Stuff most of the time renders something, but its render function can return null when it decides there's nothing to render.

Here's the twist: if <Box> is empty, I don't want to show it at all. So I decided to use css3 selectors, and write something like

.box:empty {
    display: none;
}

... which should work, except react renders a <noscript> tag, which prevents the browser from treating the parent .box element as empty...

Is there an elegant way around this? I'd like to keep the logic of determining emptiness inside of Stuff, and have Box just "look" at its contents and decide whether it wants to show anything or not.

UPDATE

This fiddle https://jsfiddle.net/69z2wepo/67543/ has an example of what I'm trying to do. Strangely, in that fiddle, it works, and react doesn't render <noscript> tags... why does it render <noscript>s in my code? In what cases does react choose to render <noscript>s?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Found the problem!

I was using an old version of react-css-modules (3.7.7). Upgrading to 4.1.0 fixed it.

Looks like this was a relatively recent fix, too: https://github.com/gajus/react-css-modules/commit/a9c8de252d5464037090e155c431abfe9f671531

over 4 years ago · Santiago Trujillo 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