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

111
Vistas
Change State - React

I define a state like this,

const [title, changeTitle] = useState('');

So, the value of the variable Title is an empty string.

Then, I receive a JSON, form :{active: '1', name: 'New Form', …}

I need to change the state title to New Form. changeTitle(form.name);

But then, the variable Title is undefined.

What am I doing wrong?

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

0

Make sure that when you call changeTitle the variable form.name is not undefined. If you are using react hooks and the variable form is a state or prop you can use a useEffect and change the state of title only when the variable form.name is defined

useEffect(() => {
 if(form.name){
  changeTitle(form.name);
 }
},[form.name]);
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