A flexible and lightweight object viewer component for React.
Inspired by Runkit.
npm install @lanyue/react-object-viewerimport { ObjectViewer } from '@lanyue/react-object-viewer'
import '@lanyue/react-object-viewer/dist/style.css'
function App() {
return (
<ObjectViewer value={window} />
)
}Preview
ObjectViewer component props:
- value:
anyThe value to be view. - showLine?:
boolean- Show alignment line. Defaults tofalse. - showLevel?:
number- Defines how many levels should be unfolded initially. Defaults to1. - showItems?:
number- Specifies the number of items to render. Defaults to20. - showInlineMax?:
number- Maximum number of items for inline rendering before switching to block format. Defaults to50. - showIcon?:
boolean- Show type icon. Defaults tofalse. - hideNonEnumerability?:
boolean- Hide non-enumerable properties. Defaults tofalse. - sort?:
number- Sorting method for items:0(default) - No sorting1- Descending order2- Ascending order
- canClickLabelExtend?:
boolean- Allow clicking on the label to expand. Defaults tofalse. - header?:
ReactNode- Custom header component. - footer?:
ReactNode- Custom footer component. - attrs?:
React.ComponentProps<'div'>- Additional attributes applied to the root<div>container. - renderValue?:
RenderValueFn- Custom function to render values. - renderTypeIcon?:
(type: Type, descriptor: TypedPropertyDescriptor<any>, level: number, DefaultIcon: typeof RenderTypeIcon) => ReactNode- Custom function to render type icons.
DefaultIconrefers to the built-in type icon renderer.
