React D3 Tree is a JavaScript library providing a React component for visualizing hierarchical data as interactive tree graphs. It leverages D3.js's `tree` layout for efficient rendering and interactivity, making it suitable for representing structures like family trees, organizational charts, or file directories. The current stable version is 3.6.6. The project maintains an active release cadence with frequent minor updates and bug fixes. Key differentiators include its declarative React interface for D3-based trees, built-in zooming, panning, and node collapsing, and strong TypeScript support, enabling developers to integrate complex visualizations with minimal setup.
npm install react-d3-treeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to render a basic organizational chart using the Tree component, providing data, setting orientation, initial translation, and path rendering style.
Refer to the v2 release notes (https://github.com/bkrem/react-d3-tree/releases/tag/v2.0.0) and the v3 API Documentation (https://bkrem.github.io/react-d3-tree/docs) for updated API usage.
Provide explicit `width` and `height` CSS properties to the container element wrapping the `<Tree />` component, e.g., `<div style={{ width: '100%', height: '500px' }}>`.Ensure package managers (`npm`, `yarn`) resolve dependencies correctly. If issues persist, verify that `@bkrem/react-transition-group` is explicitly version 1.3.5 or later and `@types/d3-hierarchy` is installed as a production dependency.
Upgrade to `react-d3-tree@3.6.4` or newer, which includes a patched version of `react-transition-group` to address these peer dependency conflicts.
Ensure `@types/d3-hierarchy` and `d3-hierarchy` (if used directly) are correctly installed and bundled. Check `package.json` and `node_modules` for consistency. Updating `react-d3-tree` to the latest version (v3.6.6+) may resolve this as it explicitly ensures `@types/d3-hierarchy` as a prod dep.
Run `npm install --save react-d3-tree` or `yarn add react-d3-tree`. Verify the import statement is `import Tree from 'react-d3-tree';`.
Ensure `react-d3-tree` is installed and that TypeScript is configured to include `node_modules/@types`. The package ships its own types, so this error might indicate an installation issue or an incorrect `tsconfig.json` setup.