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

211
Vistas
useState value not rendering in DOM

I am an absolute beginner with React, I have a component where I need to render the value of a state to the Dom but it doesnt work let me show you my code.

Links.jsx

import React, { useEffect, useState } from 'react'
import { Collapse } from 'antd'

const Links = () => {
  const [isMobile, setIsMobile] = useState(false)
  return (
    <div>
      <div>asd2</div>
      <div>{ isMobile }</div>
      <div>asd5</div>
    </div>
  )
}

export default Links

I am using it like

footer.jsx

import Links from './links'

const Footer = ({
  globalData,
  user
}) => {
return(
<Links/>
)

}

it does render the text asd2 and asd5 meaning the component itself works just not the state value. I've looked everywhere this is how everybody does it .What am I doing wrong?

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

0

Instead

<div>{ isMobile }</div>

Try this

<div>{ isMobile.toString()}</div>

Or this

<div>{ isMobile ? "true" : "false"}</div>

Even this:

<div>{`${isMobile}`}</div>

Type boolean cannot be rendered in JSX.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You need to convert isMobile it to a string. false, null & undefined these values are not rendered.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can't render a Boolean. Use it like this:

{ isMobile.toString() }
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