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

150
Vistas
Getting a property of objects in an array, as an array, using Formik's useField hook

Given a Formik context containing an array of objects:

{
  myArrayOfObjects: {
    property: string
  }[]
}

I would like to get an array of the values of property. I don't, however, have any idea whether this is possible. For further reference, I initially attempted myArrayOfObjects.property and myArrayOfObjects[].property in the hopes it would magically work, but unfortunately it does not.

The end goal here is to use this in tandem with a react-select multiselect field.

Is this possible, and if not, what would be the proper way to work this out properly?

This is on formik v2.2.6

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

0

You can transform the data to get the array. There are possible better ways to do it, but this is the idea:

const getPropertyValues = (values: InnerObject[]) => {
  const newArray: string[] = [];
  values.map((x: InnerObject) => {
    newArray.push(x.properties);
  });
  return newArray;
};

I did a CodeSandbox so you can try it. I use that same function in 2 places:

  1. To print the values of the form as an string[]
  2. In the SelectComponent to create the options that will be displayed on the react-select component
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