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

133
Views
Intentando establecer el valor del campo de entrada en formik

estoy tratando de crear un formulario de publicación de trabajo usando react , mui , formik y sí en el que estoy creando un campo de entrada de etiqueta igual que el de stackoverflow pero cuando estoy configurando el valor de la etiqueta después de agregar una nueva etiqueta usando setTags entonces está agregando el segunda última etiqueta no la última.

 import { TextField } from '@material-ui/core'; import "../../App.css"; const TagsInput = props => { const [tags, setTags] = React.useState(props.tags); const removeTags = indexToRemove => { setTags([...tags.filter((_, index) => index !== indexToRemove)]); }; const addTags = (event,tags) => { if (event.target.value !== "") { setTags([...tags, event.target.value]); props.selectedTags([...tags, event.target.value]); props.setFieldValue('tag',tags) event.target.value = ""; } }; return ( <div className="tags-input"> <ul id="tags"> {tags.map((tag, index) => ( <li key={index} className="tag"> <span className='tag-title'>{tag}</span> <span className='tag-close-icon' onClick={() => removeTags(index)} > x </span> </li> ))} </ul> <TextField type="text" onKeyUp={event => event.key === "Enter" ? addTags(event,tags) : null} placeholder="Add tags" /> </div> ); }; export default TagsInput``` Props which i have passed props = <selectedTags={selectedTags} setFieldValue={setFieldValue} tags={[]}> Example: like if i enter *html* as first tag then it sets *[]* as value of tag if i enter *css* as sencond tag then it sets *['html']* as value of tag if i enter *js* as third tag then it sets *['html','css']* as value of tag Plese help me out how can i fix this bug.
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Probablemente aumentaría sus posibilidades de obtener una respuesta al proporcionar el componente donde usa TagsInput, ya que falta la implementación de props.selectedTags(), props.setFieldValue().

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!