Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!