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

60
Views
Establece dinámicamente FieldValue en un grupo de casillas de verificación en formik

MI problema Estoy intentando establecer los valores de campo en el grupo de casillas de verificación usando la propiedad formik.setFieldValue . Estos valores provienen de una API de back-end en forma de matriz.

Mi código Estoy usando el gancho useFormik de la biblioteca formik para manejar los valores de las casillas de verificación. He configurado formik.handleChange en la función formik.handleChange de mis casillas de verificación. Aquí está el fragmento de código mínimo de mi aplicación.

 import React from "react";
import { useFormik } from "formik";



const tags = ["one", "two", "three"];

const ProjectsForm = () => {
 const formik = useFormik({
 enableReinitialize: true,
 initialValues: {
 tags: []
 },
 onSubmit: (values) => {
 console.log(values);
 }
 });

 return (
 <form onSubmit={formik.handleSubmit}>
 {tags.map((tag) => (
 <div key={tag}>
 <input
 id={tag}
 type="checkbox"
 name={tag}
 
 onChange={formik.handleChange}
 />
 <label htmlFor={tag}>{tag}</label>
 </div>
 ))}
 <button type="submit">Submit</button>
 </form>
 );
};


¿Cómo uso formik.setFieldValue para establecer el valor de mis casillas de verificación provenientes del backend?

almost 4 years ago · Santiago Trujillo
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!