react18-json-view
react18-json-view copied to clipboard
An unknown error occurs.
- "react": "^17.0.2",
- "webpack": "^5.74.0",
import React from 'react'
import JsonView from 'react18-json-view'
import 'react18-json-view/src/style.css'
export const JsonViewer = ({ data }: { data: object }) => (
<JsonView src={data} />
)
error message
The above error occurred in the <import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
import * as React from 'react';
import React__default, { useContext, useState, useCallback, useEffect, useRef, isValidElement, useMemo, createContext } from 'react';
function isObject(node) {
return Object.prototype.toString.call(node) === '[object Object]';
}
function objectSize(node) {
return Array.isArray(node) ? node.length : isObject(node) ? Object.keys(node).length : 0;
}
function stringifyForCopying(node, space) {
// return single string nodes without quotes
if (typeof node === 'string') {
return node;
}
try {
return JSON.stringify(node, (key, value) => {
switch (typeof value) {
case 'bigint':
return String(value) + 'n';
case 'number':
case 'boolean':
case 'object':
case 'string':
return value;
default:
return String(value);
}
}, space);
}
catch (error) {
return `${error.name}: ${error.message}` || 'JSON.stringify failed';
}
}
function isCollapsed(node, depth, indexOrName, collapsed, collapseObjectsAfterLength, customOptions) {
if (customOptions && customOptions.collapsed !== undefined)
return !!customOptions.collapsed;
if (typeof collapsed === 'boolean')
return collapsed;
if (typeof collapsed === 'number' && depth > collapsed)
return true;
const size = objectSize(node);
if (typeof collapsed === 'function') {
const result = safeCall(collapsed, [{ node, depth, indexOrName, size }]);
if (typeof result === 'boolean')
return result;
}
if (Array.isArray(node) && size > collapseObjectsAfterLength)
return true;
if (isObject(node) && size > collapseObjectsAfterLength)
return true;
return false;
}
function isCollapsed_largeArray(node, depth, indexOrName, collapsed, collapseObjectsAfterLength, customOptions) {
if (customOptions && customOptions.collapsed !== undefined)
return !!customOptions.collapsed;
if (typeof collapsed === 'boolean')
return collapsed;
if (typeof collapsed === 'number' && depth > collapsed)
return true;
const size = Math.ceil(node.length / 100);
if (typeof collapsed === 'function') {
const result = safeCall(collapsed, [{ node, depth, indexOrName, size }]);
if (typeof result === 'boolean')
return result;
}
if (Array.isArray(node) && size > collapseObjectsAfterLength)
return true;
if (isObject(node) && size > collapseObjectsAfterLength)
return true;
return false;
}
function ifDisplay(displaySize, depth, fold) {
if (typeof displaySize === 'boolean')
return displaySize;
if (typeof displaySize === 'number' && depth > displaySize)
return true;
if (displaySize === 'collapsed' && fold)
return true;
if (displaySize === 'expanded' && !fold)
return true;
return false;
}
function safeCall(func, params) {
try {
return func(...params);
}
catch (event) {
reportError(event);
}
}
function editableAdd(editable) {
if (editable === true)
return true;
if (isObject(editable) && editable.add === true)
return true;
}
function editableEdit(editable) {
if (editable === true)
return true;
if (isObject(editable) && editable.edit === true)
return true;
}
function editableDelete(editable) {
if (editable === true)
return true;
if (isObject(editable) && editable.delete === true)
return true;
}
function isReactComponent(component) {
return typeof component === 'function';
}
function customAdd(customOptions) {
return !customOptions || customOptions.add === undefined || !!customOptions.add;
}
function customEdit(customOptions) {
return !customOptions || customOptions.edit === undefined || !!customOptions.edit;
}
function customDelete(customOptions) {
return !customOptions || customOptions.delete === undefined || !!customOptions.delete;
}
function customCopy(customOptions) {
return !customOptions || customOptions.enableClipboard === undefined || !!customOptions.enableClipboard;
}
function customMatchesURL(customOptions) {
return !customOptions || customOptions.matchesURL === undefined || !!customOptions.matchesURL;
}
function resolveEvalFailedNewValue(type, value) {
if (type === 'string') {
return value.trim().replace(/^\"([\s\S]+?)\"$/, '$1');
}
return value;
}
var _path$8;
.....
What happend my example ?