<commit_before>import React, {Component} from 'react';

import * as types from 'reduxes/actionTypes';

export function asyncComponent(store, getComponent) {

    return class AsyncComponent extends Component {

        static Component = null;

        constructor(props) {

            super(props);

            this.state = {
                Component: AsyncComponent.Component
            };

        }

        loadStartCallback() {
            setTimeout(() => {
                store.dispatch({type: types.LOAD_COMPONENT_START});
            }, 0);
        }

        loadCompleteCallback() {
            setTimeout(() => {
                store.dispatch({type: types.LOAD_COMPONENT_COMPLETE});
            }, 0);
        }

        componentWillMount() {

            if (!this.state.Component) {

                this.loadStartCallback();

                getComponent().then(({default: Component}) => {
                    AsyncComponent.Component = Component;
                    this.setState({
                        Component
                    }, () => {
                        this.loadCompleteCallback();
                    });
                });

            }

        }

        render() {
            const {Component} = this.state;
            if (Component) {
                return <Component {...this.props} />;
            }
            return null;
        }

    };

}<commit_msg>optimize code<commit_after>import React, {Component} from 'react';

import * as types from 'reduxes/actionTypes';

export function asyncComponent(store, getComponent) {

    return class AsyncComponent extends Component {

        static Component = null;

        constructor(props) {

            super(props);

            this.state = {
                Component: AsyncComponent.Component
            };

        }

        loadStartCallback() {
            setTimeout(() => {
                store.dispatch({type: types.LOAD_COMPONENT_START});
            }, 0);
        }

        loadCompleteCallback() {
            setTimeout(() => {
                store.dispatch({type: types.LOAD_COMPONENT_COMPLETE});
            }, 0);
        }

        componentWillMount() {

            if (!this.state.Component) {

                this.loadStartCallback();

                getComponent().then(({default: Component}) => {
                    AsyncComponent.Component = Component;
                    this.setState({
                        Component
                    }, () => {
                        this.loadCompleteCallback();
                    });
                });

            }

        }

        render() {
            const {Component} = this.state;
            if (Component) {
                return <Component {...this.props} />;
            }
            return null;
        }

    };

}

export const ac = asyncComponent;
{'fraction_non_alphanumeric': 0.10975183502271933, 'fraction_numerical': 0.0013981125480601187, 'mean_word_length': 1.2606635071090047, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1060815', 'n_tokens_mistral': 698, 'n_tokens_neox': 642, 'n_words': 123}