import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { debounce } from 'lodash'; import classnames from 'classnames'; export default class SignatureRequestMessage extends PureComponent { static propTypes = { data: PropTypes.object.isRequired, onMessageScrolled: PropTypes.func, setMessageRootRef: PropTypes.func, }; static contextTypes = { t: PropTypes.func, }; messageAreaRef; state = { messageIsScrolled: false, }; setMessageIsScrolled = () => { if (!this.messageAreaRef || this.state.messageIsScrolled) { return; } const { scrollTop, offsetHeight, scrollHeight } = this.messageAreaRef; const isAtBottom = scrollTop + offsetHeight >= scrollHeight; if (isAtBottom) { this.setState({ messageIsScrolled: true }); this.props.onMessageScrolled(); } }; onScroll = debounce(this.setMessageIsScrolled, 25); renderNode(data) { return (