mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-31 23:17:29 -08:00
26 lines
502 B
TypeScript
26 lines
502 B
TypeScript
import React, { useEffect, useRef } from 'react';
|
|
|
|
const ScrollToBottomOnChanges = ({ content, changes }) => {
|
|
const messagesEndRef = useRef(null);
|
|
|
|
// @TODO (2)
|
|
const scrollToBottom = () => {
|
|
messagesEndRef.current.scrollIntoView({ behavior: 'smooth' })
|
|
}
|
|
|
|
useEffect(scrollToBottom, [changes]);
|
|
|
|
const styling = {
|
|
height: '100%'
|
|
};
|
|
|
|
return (
|
|
<div style={styling}>
|
|
{content}
|
|
<div ref={messagesEndRef} />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default ScrollToBottomOnChanges;
|