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

182
Views
Formik FieldArray get values for calculations

I am using Formik with FieldArray, and passing values of Formik to another component for cross calculations,

But now the output of values are array, so how can I get access to those individual input items from an array?

import React, { useEffect } from "react";
import {TextField} from "@mui/material";

const CalculatedFieldForArray = props => {
  useEffect(() => {

    var tax = 0;

    var array = props.values.people
    
    console.log(props.values);

    array.map((out) => {

      if (out.price) {

        tax = out.price * out.country / 100;
      }
      //...Here I don't know how to assign value to FieldArray textfield
      props.setFieldValue("quantity", tax);
      
    })
    
    props.setFieldValue("quantity", tax);
  }, [props.values]);

 
  return (
    <TextField
      type="number"
      name="quantity"
      value={props.values.quantity}
    />
  );
};

export default CalculatedFieldForArray;

values which is passed by Formik is as below which shown in console, Want to access price and country value for each input and return calculation value.

{
    "people": [
        {
            "id": 0.8646983183745629,
            "price": "11",
            "country": "20"
        },
        {
            "id": 0.3192991708409705,
            "price": "110",
            "country": "18"
        }
    ],
    "quantity": 0
}
``
about 4 years ago · Juan Pablo Isaza
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!