Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

243
Vistas
react-window scroll to bottom

I'm using react-window to render a long list to show messages. but how can I move scroll to bottom for each new messages?

I could handle it for normal Div by using useRef, but what about react-window?

const list = useRef<HTMLDivElement>(document.createElement('div'));

  useEffect(() => {
    list.current.scrollTop = list.current.scrollHeight;
  }, [message]);

and:

<FixedSizeList
  width="100%"
  height={500}
  itemCount={messages.length}
  itemSize={40}
  itemData={messages}
 >
    {Row}
 </FixedSizeList>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I'd create a ref to attach to FixedSizeList, then create a function that scrolls to the bottom of that list and have an effect that listens to when a new item is added to the list. Something like:

function ListComponent({ messages }) {
  const listRef = useRef(null);
  
  const scrollToBottom = () =>
      listRef?.current.scrollToItem(messages.length);

  useEffect(() => {
    scrollToBottom();
  }, [messages]);

  return (
    <FixedSizeList
      width="100%"
      height={500}
      itemCount={messages.length}
      itemSize={40}
      itemData={messages}
      ref={listRef}
    >
      {Row}
    </FixedSizeList>
  );
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda