<commit_before>import Webiny from 'Webiny';
import BaseContainer from './BaseContainer';

class StaticContainer extends BaseContainer {

    componentWillMount() {
        super.componentWillMount();
        this.prepare(this.props);
        this.loadData(this.props);
    }

    componentWillReceiveProps(props) {
        super.componentWillReceiveProps(props);
        this.prepare(props);
        this.loadData(props);
    }

    loadData(props) {
        const propsData = _.get(props, 'data', this.props.data);
        let data = _.isEmpty(this.state.filters) ? propsData : _.filter(propsData, this.state.filters);
        const fields = [];
        const order = [];
        _.each(this.state.sorters, (sort, field) => {
            fields.push(field);
            order.push(sort === 1 ? 'asc' : 'desc');
        });
        data = _.orderBy(data, fields, order);


        const meta = {
            currentPage: this.state.page,
            perPage: this.state.perPage,
            totalCount: data.length,
            totalPages: Math.ceil(data.length / this.state.perPage)
        };

        this.totalPages = meta.totalPages;

        const from = (this.state.page - 1) * this.state.perPage;

        this.setState({
            list: data.slice(from, from + this.state.perPage),
            meta,<commit_msg>Prevent component prepare and data load if props haven't changed.<commit_after>import Webiny from 'Webiny';
import BaseContainer from './BaseContainer';

class StaticContainer extends BaseContainer {

    componentWillMount() {
        super.componentWillMount();
        this.prepare(this.props);
        this.loadData(this.props);
    }

    componentWillReceiveProps(props) {
        super.componentWillReceiveProps(props);
        const omit = ['children', 'renderer'];
        if (_.isEqual(_.omit(props, omit), _.omit(this.props, omit))) {
            return;
        }
        this.prepare(props);
        this.loadData(props);
    }

    loadData(props) {
        const propsData = _.get(props, 'data', this.props.data);
        let data = _.isEmpty(this.state.filters) ? propsData : _.filter(propsData, this.state.filters);
        const fields = [];
        const order = [];
        _.each(this.state.sorters, (sort, field) => {
            fields.push(field);
            order.push(sort === 1 ? 'asc' : 'desc');
        });
        data = _.orderBy(data, fields, order);


        const meta = {
            currentPage: this.state.page,
            perPage: this.state.perPage,
            totalCount: data.length,
            totalPages: Math.ceil(data.length / this.state.perPage)
        };

        this.totalPages = meta.totalPages;

        const from = (this.state.page - 1) * this.state.perPage;

        this.setState({
            list: data.slice(from, from + this.state.perPage),
            meta,
{'fraction_non_alphanumeric': 0.13040421792618628, 'fraction_numerical': 0.00140597539543058, 'mean_word_length': 2.1763392857142856, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '11416', 'n_tokens_mistral': 825, 'n_tokens_neox': 799, 'n_words': 162}