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

174
Vistas
How to hide null values during render in React?

I have this API endpoint:

GET https://xxx/xx

Result:

{
    "name": "Ana",
    "status": null,
}

I render the API result inside a blank page in my App and the page contains the following:

Ana
null

I want to hide null values.I don't want 'null' to be shown at all. How can I achieve this in React/Javascript?

{name && (
                <span>
                  {name}
                  <br />
                </span>
              )}
{status && (
                <span>
                  {status}
                </span>
              )}
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

your code should work fine , I think you need to convert your api response to json.

Exemple

const response = await fetch(URL);
const jsonResponse = await response.json();
about 4 years ago · Juan Pablo Isaza Denunciar

0

This is correct from what you have told me in the comments I think that you have some default value set for the response that status is a string. Please verify it.

const [status, setStatus] = useState<string | null>(null);
{status && (
                <span>
                  {status}
                </span>
              )}

when you are setting it with setStatus make sure that the value is not null like this

if (response.data.status) {
  setStatus(response.data.status)
} 
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