React JSON View (RJV) is an interactive React component designed for displaying and optionally editing JavaScript arrays and JSON objects within web applications. The version provided (1.21.3) from the `mac-s-g/react-json-view` repository has announced it is no longer actively maintained. However, an actively maintained fork exists at `@microlink/react-json-view`, which offers ongoing updates, performance improvements, and additional features, including full TypeScript support and a redesigned API in its v2. The original `mac-s-g` version is transpiled to ES5, ensuring broad compatibility. Key differentiators of both versions include extensive theme support (base-16), customizable expand/collapse behavior, optional editing features via callbacks, clipboard functionality, and various display options for data types and object sizes.
npm install react-json-viewVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to integrate `ReactJson` into a functional React component, displaying a sample JSON object with various data types. It shows how to enable editing, adding, and deleting properties using the `onEdit`, `onAdd`, and `onDelete` callbacks, and configures several display options like themes, collapse depth, and data types.
Migrate to `@microlink/react-json-view` by installing `npm install @microlink/react-json-view` and updating imports to `import ReactJson from '@microlink/react-json-view'`.
Provide a function to `onEdit`, `onAdd`, or `onDelete` (e.g., `onEdit={myEditCallback}`) to activate the respective editing capabilities. Returning `false` from these callbacks will prevent the update.Use `collapsed={true}` to collapse everything, `collapsed={false}` to expand everything, or `collapsed={N}` where `N` is an integer for specific depth collapsing. For more granular control, use the `shouldCollapse` callback prop.Ensure your project's `react` and `react-dom` versions fall within the specified peer dependency range. If using React 18+, consider using the `@microlink/react-json-view` fork, which explicitly supports newer React versions.
Ensure you are using the correct default import syntax: `import ReactJson from 'react-json-view'`. If using CommonJS, explicitly access the default export: `const ReactJson = require('react-json-view').default`.Check your `package.json` for `react` and `react-dom` versions and ensure they satisfy the `react-json-view` peer dependency range (`^17.0.0 || ^16.3.0 || ^15.5.4`). Run `npm install` or `yarn install` to resolve dependencies. For React 18+, consider using `@microlink/react-json-view`.