I am building a chat application. Although everything is working perfectly fine. But the problem here is when user types new msg it goes below the chat display area and user have to manually scroll down to see the message. I want to know how can I resolve this issue in my app. so that when message is submitted the it appears immediately in the chat area.
Here is my code .
chatRoomPage.js
<Grid item xs={12}>
<div style={{maxHeight: '500px', height: '500px',
position: 'fixed',width:'100%',
overflow: 'auto'}}>
{receivedMessage && receivedMessage.content &&
receivedMessage.content.map((item,index) => {
if(item.senderId === item.vendorId) {
return (
<ChatThread key={index} image={item.senderImage} right={true} content={item.content}/>
)
}else {
return (
<ChatThread key={index} image={item.reciverImage} content={item.content}/>
)}
}) }
</div>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</Grid>
This is the ui