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

171
Views
Error al ejecutar 'getComputedStyle' en 'Ventana': el parámetro 1 no es del tipo de error 'Elemento' en React

Estoy tratando de hacer un cuadro de texto de expansión automática (hacia arriba) con JavaScript en una aplicación React. Tengo este error. También intenté usar window.getElementbyId en lugar de pero eso no funciona.

 [![error image][1]][1]
 <ReactTextareaAutocomplete id="textbox" className="message-input" placeholder="Type your message.."/>
 const tx = document.getElementsByTagName("ReactTextareaAutocomplete"); const maxheight = 100; const normalheight = window.getComputedStyle(tx[0]).getPropertyValue('height').replace("px", ""); for (let i = 0; i < tx.length; i++) { tx[i].setAttribute("style", "margin-top:-3px;" + "height:" + (tx[i].scrollHeight > maxheight ? maxheight : tx[i].scrollHeight) + "px;overflow-y:hidden;"); tx[i].addEventListener("input", OnInput, false); } function OnInput() { this.style.marginTop = (normalheight - this.style.height.replace("px", "")) + "px"; this.style.height = "auto"; this.style.height = (this.scrollHeight > maxheight ? maxheight : this.scrollHeight) + "px"; } [1]: <https://i.stack.imgur.com/1UbRS.png>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Implemente useRef() en su lugar para acceder al elemento.

Agregue el atributo ref en el elemento.

 <ReactTextareaAutocomplete ref={rtaRef} />

Y para la función:

 const tx = useRef(null);

Si tiene varias instancias del componente, use el bucle para crear una ref única usando el índice del bucle.

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!