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

115
Views
¿Cómo arreglar violetion tardó 200 ms al desplazarse por un bloque con la carga del mensaje?

Cargo mensajes por 20 piezas, actualizo el estado cuando llega a 0 en el desplazamiento y giro el bloque 20 mensajes hacia atrás. Pero después de algunos desplazamientos, la página se congela y recibo una advertencia en la consola: [Violación] El controlador de 'mensaje' tardó 187 ms

Probé e.preventDefault() - no funcionó, e.stopPropagation() - similar. Por favor dime que hice mal?

 onScroll={(e) => { if(e.target.scrollTop < 1) { const msgID = prevMessages.length ? parseInt(prevMessages[0].id) : parseInt(messages[0].id); console.log(msgID); socket.emit('getPrevMessages', {roomId, msgID}); e.target.scrollTo(0, e.target.querySelector('.direct-chat-msg:nth-child(20)').offsetTop); e.stopPropagation(); } }}

Gracias.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

import { useState, useCallback } from 'react'; function debounce(func, wait) { let timeout; return () => { if (timeout) { clearTimeout(timeout); } timeout = setTimeout(func, wait) } } const changeHandler = (e) => { if(e.target.scrollTop < 1) { const msgID = prevMessages.length ? parseInt(prevMessages[0].id) : parseInt(messages[0].id); console.log(msgID); socket.emit('getPrevMessages', {roomId, msgID}); e.target.scrollTo(0, e.target.querySelector('.direct-chat-msg:nth-child(20)').offsetTop); e.stopPropagation(); } } const debouncedChangeHandler = useCallback( debounce(changeHandler, 250) , []); onScroll={ debouncedChangeHandler}
about 4 years ago · Juan Pablo Isaza Report

0

El trabajo pero mi controlador no actualiza los mensajes de estado y los mensajes previos todo el tiempo dos matrices vacías

 const debounce = (func, wait) => { let timeout; return (() => { if (timeout) { clearTimeout(timeout); } timeout = setTimeout(() => func(), wait) })(); } const changeHandler = (e) => { console.log(e); if(e.target.scrollTop < 1) { const msgID = prevMessages.length ? parseInt(prevMessages[0].id) : parseInt(messages[0].id); console.log(msgID); socket.emit('getPrevMessages', {roomId, msgID}); //e.stopPropagation(); } } const debouncedChangeHandler = useCallback((e) => debounce(() => changeHandler(e), 250),[]);
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!