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

104
Views
¿Cómo puedo hacer un envío a una matriz y configurar el Estado con los datos sin causar un bucle?

Estoy presionando la matriz con los datos, pero cuando configuré la matriz en el estado, obtuve varios objetos en la consola, con el mismo contenido.

Cuando los datos en los que se hizo clic en el mapa no son iguales a los primeros datos en la matriz, el usuario aún puede hacer clic en otras coordenadas. :

 const [showPolygonForm, setShowPolygonForm] = useState(false) const [polyData, setPolyData] = useState([]) const revealPolygonForm = () => { setShowPolygonForm(!showPolygonForm) } const createPolygon = () => { let arrayValores = [] if(showPolygonForm === true){ map.on('click', e => { const data = { lat: e.latlng.lat, lng: e.latlng.lng } arrayValores.push(data) setPolyData(arrayValores) console.log(arrayValores) })} if(polyData[0] != polyData[(polyData.length - 1)]){ console.log("it's in") map.on('click', e => { arrayValores.push(e.latlng) })} } createPolygon()
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!