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

159
Vistas
How do I access object's values inside of Array in React?

I'm working on a React App where I'm passing an array that holds various values for each index and passing it to a prop, but for some reason its not displaying the text inside of my h1. I'm not receiving an error for it, and I've tried researching a bit but I'm unable to find any concrete information.

State: var [editTask, setEditTask] = useState([]);

How I'm writing to the state(works correctly) Keep in mind, im only storing 1 element, this will never have multiple:

setEditTask([{
  text: todo.text,
  status: todo.status,
  id: todo.id,
  priority: todo.priority,
}]);

How i'm trying to get the text from the array:

return (
  <div>
    <h1>{props.editTask.id}</h1>
  </div>
)
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Try using the native javascript Object.values() method.

about 4 years ago · Juan Pablo Isaza Denunciar

0

If you are storing only one element you don't need an array of objects. Can be done with a single object.

const [editTask, setEditTask] = useState({});

useEffect(() => {
  setEditTask({
    ...todo,
  });
}, [todo]);

// Inside component
return (
  <div>
    {Object.values(props.editTask).map((val) => (
      <h1>{val}</h1>
    ))}
  </div>
);

Without changing current structure

return (
  <div>{ editTask.map((val) => <h1>{val.status}</h1>)}</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