1
votes

I have a js file next.js that takes json as input and draws graphics, if I create an html file and import the file next.js, then everything works without errors, if I import the file using react, then the code is not works and there are many errors, what am I doing wrong?

enter image description here

enter image description here

fragment of the file next.js:

var nx = {
    VERSION: "0.8",
    DEBUG: !1,
    global: function() {
        return this
    }.call(null)
};
console.log(nx),
! function() {
    Function.prototype.bind || (Function.prototype.bind = function(a) {
        var b = this;
        return function() {
            return b.apply(a, arguments)
        }
    })
}(),
function(a) {
    var b = Array.isArray || function(a) {
            return a && a.constructor === Array
        },
        c = function(a) {
            var b = Object.prototype.hasOwnProperty;
            if(!a || "[object Object]" !== Object.prototype.toString(a) || a.nodeType || a === window) return !1;
            try {
                if(a.constructor && !b.call(a, "constructor") && !b.call(a.constructor.prototype, "isPrototypeOf")) return !1
            } catch(c) {
                return !1
            }
            var d;
            for(d in a);
            return void 0 === d || b.call(a, d)
        };
    a.extend = function(a) {
        for(var b = 1, c = arguments.length; c > b; b++) {
            var d = arguments[b];
            for(var e in d) d.hasOwnProperty(e) && (a[e] = d[e])
        }
        return a
    }, a.each = function(c, d, e) {
        if(c && d)
            if(c.__each__) c.__each__(d, e);
            else if(b(c) || "[object Arguments]" === Object.prototype.toString.call(c) || a.global.NodeList && c instanceof NodeList || a.global.HTMLCollection && c instanceof HTMLCollection)
            for(var f = 0, g = c.length; g > f && d.call(e, c[f], f) !== !1; f++);
        else
            for(var h in c)
                if(c.hasOwnProperty(h) && d.call(e, c[h], h) === !1) break
    }, a.clone = function() {
        var d = function() {
            var a, d, e, f, g;
            return a = function(a, b) {
                for(var c = 0; c < a.length; c++)
                    if(a[c].key === b) return a[c].value;
                return null
            }, d = function(a, b, c) {
                var d;
                for(d = 0; d < a.length; d++)
                    if(a[d].key === b) return void(a[d].value = c);
                a[d] = {
                    key: b,
                    value: c
                }
            }, e = function(a) {
                return 0 === a.length ? null : a[a.length - 1]
            }, f = function(a) {
                var b = [];
                if("[object Array]" == Object.prototype.toString.call(a))
                    for(var c = 0; c < a.length; c++) b.push(c);
                else
                    for(var d in a) b.push(d);
                return b
            }, g = function(g) {
                if(window === g || document === g) return null;
                if(["null", "undefined", "number", "string", "boolean", "function"].indexOf(typeof g) >= 0) return g;
                if(!b(g) && !c(g)) return g;
                var h, i, j, k = [],
                    l = [],
                    m = g,
                    n = b(g) ? [] : {};
                for(d(k, m, n), l.push({
                        origin: m,
                        dest: n,
                        keys: f(m),
                        idx: 0
                    });;) {
                    if(h = e(l), !h) break;
                    if(m = h.origin, n = h.dest, h.keys.length <= h.idx) l.pop();
                    else {
                        if(i = h.keys[h.idx++], b(m[i])) n[i] = [];
                        else {
                            if(!c(m[i])) {
                                n[i] = m[i];
                                continue
                            }
                            n[i] = {}
                        }
                        j = a(k, m[i]), j ? n[i] = j : (d(k, m[i], n[i]), l.push({
                            origin: m[i],
                            dest: n[i],
                            keys: f(m[i]),
                            idx: 0
                        }))
                    }
                }
                return n
            }
        }();
        return function(b, c) {
            if(b) {
                if(b.__clone__) return b.__clone__(c);
                if(c) return d(b);
                if(a.is(b, "Array")) return b.slice(0);
                var e = {};
                for(var f in b) b.hasOwnProperty(f) && (e[f] = b[f]);
                return e
            }
            return b
        }
    }(), a.is = function(a, d) {
        if(a && a.__is__) return a.__is__(d);
        switch(d) {
            case "Undefined":
                return void 0 === a;
            case "Null":
                return null === a;
            case "Object":
                return a && "object" == typeof a;
            case "String":
            case "Boolean":
            case "Number":
            case "Function":
                return typeof a === d.toLowerCase();
            case "Array":
                return b(a);
            case "POJO":
                return c(a);
            default:
                return a instanceof d
        }
    }, a.get = function(a, b) {
        return a ? a.__get__ ? a.__get__(b) : a[b] : void 0
    }, a.set = function(a, b, c) {
        a && (a.__set__ ? a.__set__(b) : a[b] = c)
    }, a.gets = function(a) {
        if(a) {
            if(a.__gets__) return a.__gets__();
            var b = {};
            for(var c in a) a.hasOwnProperty(c) && (b[c] = a[c]);
            return b
        }
    }, a.sets = function(a, b) {
        if(a && b)
            if(a.__sets__) a.__sets__(b);
            else
                for(var c in b) b.hasOwnProperty(c) && (a[c] = b[c])
    }, a.has = function(a, b) {
        return a ? a.__has__ ? a.__has__(b) : b in a : !1
    }, a.compare = function(a, b) {
        return a && a.__compare__ ? a.__compare__(b) : a === b ? 0 : a > b ? 1 : b > a ? -1 : 1
    }, a.path = function(a, c, d) {
        var e = a;
        if(c) {
            var f, g, h, i = 0;
            if("string" == typeof c) f = c.split(".");
            else {
                if(!b(c)) return a;
                f = c
            }
            if(h = f.length, void 0 === d)
                for(; e && h > i; i++) g = f[i], e = e.__get__ ? e.__get__(g) : e[g];
            else {
                for(h -= 1; e && h > i; i++) g = f[i], e = e.__get__ ? e.__get__(g) : e[g] = e[g] || {};
                g = f[i], e && (e.__set__ ? e.__set__(g, d) : e[g] = d, e = d)
            }
        }
        return e
    }, a.idle = function() {}, a.identity = function(a) {
        return a
    }, a.uuid = function() {
        return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(a) {
            var b = 16 * Math.random() | 0,
                c = "x" == a ? b : 3 & b | 8;
            return c.toString(16)
        }).toUpperCase()
    }
}(nx)
It looks like those are linter errors. Either remove those lint rules from your react project, or fix the errors they're catching. - Daniel Beck