While the below piece of code works find in d3v3, it fails in v4.
var nodes = tree.nodes(root).reverse(), links = tree.links(nodes);
import { hierarchy, tree } from 'd3-hierarchy' // create a hierarchy from the root const treeRoot = hierarchy(root) tree(treeRoot) // nodes const nodes = treeRoot.descendants() // links const links = treeRoot.links()