Commit a617ecef authored by Alexander Kotov's avatar Alexander Kotov

scroll to last message

parent 5c3d5e00
import React from 'react'
import React, { Component } from 'react'
import Message from './Message'
const Messages = (props) => {
return (
<div id="messages">
{ props.messages.map((m, i) => <Message key={i} message={m} />) }
</div>
)
class Messages extends Component {
render() {
return (
<div id="messages">
{ this.props.messages.map((m, i) => <Message key={i} message={m} />) }
</div>
)
}
scrollToLastMessage() {
let lastNode = document
.querySelector('#messages>div:last-child')
lastNode && lastNode.scrollIntoView(false)
}
componentDidMount() {
this.scrollToLastMessage()
}
componentDidUpdate() {
this.scrollToLastMessage();
}
}
export default Messages
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment