<commit_before>import React from 'react';
import isPlainObject from 'lodash.isplainobject';
import buildClassName from './buildClassName';
import isYummiesClass from './isYummiesClass';
import convertToReact from './convertToReact';
import mergeWithProps from './mergeWithProps';

/*
    'inherit' from React
*/
const Yummies = Object.create(React);

/*
    .render({ block: 'test' }, document.body, function() {})
*/
Yummies.render = function(json, ...rest) {
    return React.render(convertToReact(json), ...rest);
};

/*
    .renderToString({ block: 'test' })
*/
Yummies.renderToString = function(json) {
    return React.renderToString(convertToReact(json));
};

/*
    .renderToStaticMarkup({ block: 'test' })
*/
Yummies.renderToStaticMarkup = function(json) {
    return React.renderToStaticMarkup(convertToReact(json));
};

/*
    .createElement({ block: 'test' })
    .createElement(class extends Yummies.Component {})
    .createElement('div', { foo: 'bar' }, [ … ])
*/
Yummies.createElement = function(arg, ...rest) {
    if (isPlainObject(arg)) {
        return convertToReact(arg);
    }

    if (isYummiesClass(arg)) {
        return React.createElement(
            Yummies._prepareClass(
                Yummies._processMixins(arg)
            ),
            ...rest
        );
    }

    return React.createElement(arg, ...rest);
};

/*
    .createFactory(class extends Yummies.Component {})
    .createFactory('div')
*/
Yummies.createFactory = function(arg) {
    if (isYummiesClass(arg)) {
        return React.createFactory(
            Yummies._prepareClass(
                Yummies._processMixins(arg)
            )
        );
    }

    return React.createFactory(arg);
};

Yummies.Component = class extends React.Component {};

/*
    Prepare class before the factory.
*/
Yummies._prepareClass = function(Base) {
    return class extends Base {
        constructor(props) {
            super(props);
        }

        render() {
            const result = super.render();

            if (!isPlainObject(result)) {
                return result;
            }

            mergeWithProps(result, this.props);

            return convertToReact(result);
        }
    };
};

/*
    Extends the Base class within `mixins` static property.
*/
Yummies._processMixins = function(Base) {
    let Result = Base;

    if (Result.hasOwnProperty('mixins')) {
        Result.mixins.forEach(mixinClassFabric => {
            Result = mixinClassFabric(Result);
        });
    }

    return Result;
};
<commit_msg>:heavy_check_mark: remove unwanted `constructor()` from `_prepareClass()`<commit_after>import React from 'react';
import isPlainObject from 'lodash.isplainobject';
import buildClassName from './buildClassName';
import isYummiesClass from './isYummiesClass';
import convertToReact from './convertToReact';
import mergeWithProps from './mergeWithProps';

/*
    'inherit' from React
*/
const Yummies = Object.create(React);

/*
    .render({ block: 'test' }, document.body, function() {})
*/
Yummies.render = function(json, ...rest) {
    return React.render(convertToReact(json), ...rest);
};

/*
    .renderToString({ block: 'test' })
*/
Yummies.renderToString = function(json) {
    return React.renderToString(convertToReact(json));
};

/*
    .renderToStaticMarkup({ block: 'test' })
*/
Yummies.renderToStaticMarkup = function(json) {
    return React.renderToStaticMarkup(convertToReact(json));
};

/*
    .createElement({ block: 'test' })
    .createElement(class extends Yummies.Component {})
    .createElement('div', { foo: 'bar' }, [ … ])
*/
Yummies.createElement = function(arg, ...rest) {
    if (isPlainObject(arg)) {
        return convertToReact(arg);
    }

    if (isYummiesClass(arg)) {
        return React.createElement(
            Yummies._prepareClass(
                Yummies._processMixins(arg)
            ),
            ...rest
        );
    }

    return React.createElement(arg, ...rest);
};

/*
    .createFactory(class extends Yummies.Component {})
    .createFactory('div')
*/
Yummies.createFactory = function(arg) {
    if (isYummiesClass(arg)) {
        return React.createFactory(
            Yummies._prepareClass(
                Yummies._processMixins(arg)
            )
        );
    }

    return React.createFactory(arg);
};

Yummies.Component = class extends React.Component {};

/*
    Prepare class before the factory.
*/
Yummies._prepareClass = function(Base) {
    return class extends Base {
        render() {
            const result = super.render();

            if (!isPlainObject(result)) {
                return result;
            }

            mergeWithProps(result, this.props);

            return convertToReact(result);
        }
    };
};

/*
    Extends the Base class within `mixins` static property.
*/
Yummies._processMixins = function(Base) {
    let Result = Base;

    if (Result.hasOwnProperty('mixins')) {
        Result.mixins.forEach(mixinClassFabric => {
            Result = mixinClassFabric(Result);
        });
    }

    return Result;
};

{'fraction_non_alphanumeric': 0.13778747026169708, 'fraction_numerical': 0.0, 'mean_word_length': 2.6164874551971327, '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': '7171516', 'n_tokens_mistral': 1506, 'n_tokens_neox': 1496, 'n_words': 293}