If you want to bind custom logic to resize event, nowadays you may start using ResizeObserver browser API for the bounding box of an SVGElement.
This will also handle the case when container is resized because of the nearby elements size change.
There is a polyfill for broader browser support.
This is how it may work in UI component:
function redrawGraph(container, { width, height }) {_x000D_
d3_x000D_
.select(container)_x000D_
.select('svg')_x000D_
.attr('height', height)_x000D_
.attr('width', width)_x000D_
.select('rect')_x000D_
.attr('height', height)_x000D_
.attr('width', width);_x000D_
}_x000D_
_x000D_
// Setup observer in constructor_x000D_
const resizeObserver = new ResizeObserver((entries, observer) => {_x000D_
for (const entry of entries) {_x000D_
// on resize logic specific to this component_x000D_
redrawGraph(entry.target, entry.contentRect);_x000D_
}_x000D_
})_x000D_
_x000D_
// Observe the container_x000D_
const container = document.querySelector('.graph-container');_x000D_
resizeObserver.observe(container)
_x000D_
.graph-container {_x000D_
height: 75vh;_x000D_
width: 75vw;_x000D_
}_x000D_
_x000D_
.graph-container svg rect {_x000D_
fill: gold;_x000D_
stroke: steelblue;_x000D_
stroke-width: 3px;_x000D_
}
_x000D_
<script src="https://unpkg.com/resize-observer-polyfill@1.5.1/dist/ResizeObserver.js"></script>_x000D_
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>_x000D_
_x000D_
<figure class="graph-container">_x000D_
<svg width="100" height="100">_x000D_
<rect x="0" y="0" width="100" height="100" />_x000D_
</svg>_x000D_
</figure>
_x000D_
// unobserve in component destroy method
this.resizeObserver.disconnect()