Releases: bkrem/react-d3-tree
Releases · bkrem/react-d3-tree
v3.1.0
v3.0.0
- refactor: aligns
onNodehandler parameter signatures withonLinkhandlers (#349)- BREAKING CHANGE: All top-level
onNodehandlers now passnode: HierarchyPointNode<TreeNodeDatum>as their first parameter instead of previousnode: TreeNodeDatum. - This change affects the following event handlers:
onNodeClick,onNodeMouseOver,onNodeMouseOut. - If you're currently using
v2.x, you can preserve your existing handler behaviour inv3.xby simply accessing thedataproperty on the passednode:- v2:
onNodeClick={ (node, event) => { console.log(node) } } - v3:
onNodeClick={ (node, event) => { console.log(node.data) } }
- v2:
- The change aligns
Nodehandlers with those ofLink, which already returnHierarchyPointNode<TreeNodeDatum>for theirsourceNodeandtargetNodeparameters. - See the updated type definition for
TreeNodeEventCallbackfor more details.
- BREAKING CHANGE: All top-level
v2.0.4
- fix(zoomable): allows for dragging without scaling if
props.zoomableis set tofalse. - fix(ts): widens type for
RawNodeDatum["attributes"](#350)attributeswas made unintentionally restrictive during the v2 refactor to Typescript, by moving from a loose implicitobjecttype toRecord<string,string>.- This change widens the used
Recordtype to additionally acceptnumberandbooleanprimitives as possible values. - See the
RawNodeDatumdocs for more details.
v2.0.2
v2.0.1
v2.0.0
What's new in v2
This list is intended as an overview of important breaking changes that were introduced with v2.0.0.
For a list of all changes compared to v1, please see the changelog.
General
- Bumped React peer dependency: new minimum is
react@16.x, supportsreact@17.x. - Removed
d3as peer dependency: the specific D3 modules that are necessary forreact-d3-treeto function (d3-hierarchy, d3-selection, d3-shape, d3-zoom) have instead been included as direct dependencies. This means:- Using
react-d3-treedoes no longer require any version ofd3to be present as a peer dependency. - Mitigates an issue where multiple versions of D3 may conflict with each other (#125).
- Using
- Typescript-first: all internal components (except unit tests) have been refactored to Typescript.
- Transpiled code in the package is no longer minified by default (thankfully!). This means:
- More useful stack traces.
- Easier debugging.
- Simpler demo integration: the demo/playground app now lives inside the repo's
demodirectory. The separatereact-d3-tree-demorepo will be archived. - Removed reliance on
*.cssfiles:react-d3-treeno longer uses any CSS files internally for styling.- Importing CSS files globally (i.e.
import "./styles.css") can cause resolution issues with some libraries/frameworks (e.g. Next.js).
- Importing CSS files globally (i.e.
- Renamed internal CSS classNames for clarity and consistency.
- If you were relying on
react-d3-tree's internal classNames, please ensure you update references in your own CSS (e.g..linkBase -> .rd3t-link). - The full list of internally used CSS classNames can be found here.
- If you were relying on
API
- Removed
treeUtilsexport.treeUtilshas been removed to avoid redundant complexity, abstraction and bloat in the library's package.- If needed for your use case, the functionality
treeUtilsprovided can be achieved by leveraging some additional D3 modules, such as d3.csvParse + d3.stratify.
- Moved animations behind
enableLegacyTransitionsprop. Animations are now disabled by default.- This has been done due to
react-d3-treestill requiringreact-transition-group@1internally. - I spent a lot of time trying to get newer major versions of
react-transition-group(and a couple of other libraries) to play nice with D3's imperative approach - without success - at which point I decided to move ahead with other pressing issues for v2. - It is recommended to avoid the
enableLegacyTransitionsflag if possible, as animations can be slow in large trees and you may see compatibility warnings in your console due toreact-transition-group@1relying on React lifecycle methods that will be deprecated in React 18.x.
- This has been done due to
- Tweaked node event handler naming to be clearer and more consistent (e.g.
onClick → onNodeClick). - Removed deprecated
circleRadiusprop. - Removed
textLayoutprop.- Responsive text layouts can now be achieved via the new
renderCustomNodeElementprop. - As a starting point, feel free to check out the demo's
PureSvgNodeElementexample
- Responsive text layouts can now be achieved via the new
- Removed
stylesprop. Styling nodes & links is now best handled via:- the new
classNameprops:svgClassNamepathClassFuncrootNodeClassNamebranchNodeClassNameleafNodeClassName
- the new
renderCustomNodeElementprop.
- the new
- Removed
useCollapseDataprop.- Reason: one of the key focuses for v2 was to move away from mixing concerns (raw input data and styling/tree state) inside
data.
- Reason: one of the key focuses for v2 was to move away from mixing concerns (raw input data and styling/tree state) inside
- Consolidated the
RawNodeDatuminterface (i.e. the expected shape of nodes indata):- Merged distinct
data._childrenanddata.childreninto single
data.childrenkey. - Created
data.__rd3tkey to separate rd3t-specific data points from user input data:data._collapsed->data.__rd3t.collapseddata._depth->data.__rd3t.depthdata.id->data.__rd3t.id
- Merged distinct