<commit_before>var React = window.React;
if (React) {
    var origCreateClass = React.createClass;
    React.createClass = function (origOpts) {
        function cleanUpTScopes (inst) {
            _.each(inst.tscopes || [], function (tscope) {
                tscope.destroy();
            });
            inst.tscopes = null;
        }
        function doUpdate (inst) {
            if (!inst.hasUpdateQueued) {
                inst.hasUpdateQueued = true;
                cleanUpTScopes(inst);
                if (inst.isMounted()) {
                    inst.forceUpdate();
                    // console.log(inst.getDOMNode());
                }
            }
        }
        function getWrapperFn (origFn, isFirstWrappedEvent) {
            if (origFn || isFirstWrappedEvent) {
                return function () {
                    var self = this, args = arguments;
                    if (isFirstWrappedEvent) {
                        cleanUpTScopes(self);
                        self.hasUpdateQueued = false;
                    }
                    var rval;
                    if (origFn) {
                        var firstRun = true;
                        var tscope = T(function () {
                            if (firstRun) {
                                rval = origFn.apply(self, args);
                                // console.log('render', self._currentElement.type.displayName);
                                firstRun = false;
                            } else {
                                // console.log('update', self._currentElement.type.displayName);
                                doUpdate(self);
                            }
                        }, tbone.priority.view);
                        tscope.isView = true;
                        if (!self.tscopes) {
                            self.tscopes = [];
                        }
                        self.tscopes.push(tscope);
                    }
                    return rval;
                };
            } else {
                return undefined;
            }
        }

        var componentDidMount = origOpts.componentDidMount ? function () {
            var self = this, args = arguments;
            var rval;
            var tscope = T(function () {
                // Run and re-run componentDidMount until this component is
                // no longer mounted.
                if (self.isMounted()) {
                    rval = origOpts.componentDidMount.apply(self, args);
                }
            });
            tscope.isView = true;
            return rval;
        } : undefined;

        var opts = _.extend({}, origOpts, {
            componentWillUnmount: function () {
                cleanUpTScopes(this);
                if (origOpts.componentWillUnmount) {
                    return origOpts.componentWillUnmount.apply(this, arguments);
                } else {
                    return undefined;
                }
            },
            componentDidMount: componentDidMount,
            componentWillUpdate: getWrapperFn(origOpts.componentWillUpdate, true),
            componentDidUpdate: getWrapperFn(origOpts.componentDidUpdate, false),
            render: getWrapperFn(origOpts.render, false)
        });
        return origCreateClass(opts);
    };
}<commit_msg>React doesn't see undefined functions as the same as not being present<commit_after>var React = window.React;
if (React) {
    var origCreateClass = React.createClass;
    React.createClass = function (origOpts) {
        function cleanUpTScopes (inst) {
            _.each(inst.tscopes || [], function (tscope) {
                tscope.destroy();
            });
            inst.tscopes = null;
        }
        function doUpdate (inst) {
            if (!inst.hasUpdateQueued) {
                inst.hasUpdateQueued = true;
                cleanUpTScopes(inst);
                if (inst.isMounted()) {
                    inst.forceUpdate();
                    // console.log(inst.getDOMNode());
                }
            }
        }
        function getWrapperFn (origFn, isWillUpdate) {
            return function () {
                var self = this, args = arguments;
                if (isWillUpdate) {
                    cleanUpTScopes(self);
                    self.hasUpdateQueued = false;
                }
                var rval;
                if (origFn) {
                    var firstRun = true;
                    var tscope = T(function () {
                        if (firstRun) {
                            rval = origFn.apply(self, args);
                            // console.log('render', self._currentElement.type.displayName);
                            firstRun = false;
                        } else {
                            // console.log('update', self._currentElement.type.displayName);
                            doUpdate(self);
                        }
                    }, tbone.priority.view);
                    tscope.isView = true;
                    if (!self.tscopes) {
                        self.tscopes = [];
                    }
                    self.tscopes.push(tscope);
                }
                return rval;
            };
        }

        var opts = _.extend({}, origOpts, {
            componentWillUnmount: function () {
                cleanUpTScopes(this);
                if (origOpts.componentWillUnmount) {
                    return origOpts.componentWillUnmount.apply(this, arguments);
                } else {
                    return undefined;
                }
            },
            componentWillUpdate: getWrapperFn(origOpts.componentWillUpdate, true),
            render: getWrapperFn(origOpts.render)
        });

        if (origOpts.componentDidUpdate) {
            opts.componentDidUpdate = getWrapperFn(origOpts.componentDidUpdate);
        }
        if (origOpts.componentDidMount) {
            opts.componentDidMount = getWrapperFn(origOpts.componentDidMount);
        }

        return origCreateClass(opts);
    };
}
{'fraction_non_alphanumeric': 0.09050445103857567, 'fraction_numerical': 0.0, 'mean_word_length': 1.1087938825165102, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2933492', 'n_tokens_mistral': 1482, 'n_tokens_neox': 1425, 'n_words': 270}