Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

140
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda