<commit_before>import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import MessageListItem from './message_list_item';
import {mapObject} from '../../utils'
import {ListGroup} from 'react-bootstrap';

export default class MessageList extends Component {

    constructor(props) {
        super(props);
    }

    componentDidUpdate  (prevProps) {
        const msgList = this.refs.msgList;
        msgList.scrollTop = msgList.scrollHeight;
    }

    renderChatListItem(index, message) {
        return (
            <MessageListItem
                key={index}
                text={message.msg}
                user={message.user}
                picture={message.picture}
                uid={message.playerId}
                event_type={message.event_type}
                time={message.time}
            />
        );
    }

    render() {
        const { messages } = this.props;

        return (
            <div ref="msgList" className="chatbox-message-list">
                <ListGroup>
                    {mapObject(messages, this.renderChatListItem)}
                </ListGroup>
            </div>
        );
    }
}
<commit_msg>Fixed messages auto scrolling to bottom on every update<commit_after>import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import MessageListItem from './message_list_item';
import {mapObject} from '../../utils'
import {ListGroup} from 'react-bootstrap';

export default class MessageList extends Component {

    constructor(props) {
        super(props);
    }

    componentDidUpdate  (prevProps) {
        const msgList = this.refs.msgList;
        if (this.props.messages.length === prevProps.messages.length + 1) {
            // Scroll to bottom
            msgList.scrollTop = msgList.scrollHeight;
        }
        
    }

    renderChatListItem(index, message) {
        return (
            <MessageListItem
                key={index}
                text={message.msg}
                user={message.user}
                picture={message.picture}
                uid={message.playerId}
                event_type={message.event_type}
                time={message.time}
            />
        );
    }

    render() {
        const { messages } = this.props;

        return (
            <div ref="msgList" className="chatbox-message-list">
                <ListGroup>
                    {mapObject(messages, this.renderChatListItem)}
                </ListGroup>
            </div>
        );
    }
}

{'fraction_non_alphanumeric': 0.1088950937375349, 'fraction_numerical': 0.00039888312724371757, 'mean_word_length': 1.7350054525627046, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6604086', 'n_tokens_mistral': 675, 'n_tokens_neox': 641, 'n_words': 135}