Skip to content
Snippets Groups Projects
Unverified Commit 517f99ea authored by Avanish Singh's avatar Avanish Singh Committed by GitHub
Browse files

Delete frontend-react/src/components/Message_Area.js

parent 1b708e95
No related branches found
No related tags found
No related merge requests found
import React, {useEffect, useRef} from 'react';
import LeftMessage from "./Left_message";
import RightMessage from "./Right_message";
import '../styles/style.css';
const MessageArea = (props) => {
const End = useRef(null)
useEffect(() => {
if(props.messages.length > 0) {
scrollToBottom();
}
})
function scrollToBottom() {
End.current.scrollIntoView({behavior: "smooth"})
}
return (
<div className={props.area}>
{props.messages.map(mes => {
switch (mes.type) {
case "right":
return <RightMessage right_message={mes}/>;
case "left":
return <LeftMessage left_message={mes}/>;
}
})}
<div ref={End}></div>
</div>
);
};
export default MessageArea;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment