I have a project now where I'm building lots of custom D3 components and realizing that I can build the views to react to lens-scoped part(s) of the app state data structure by running through the generic 'update pattern' in D3, and specifying enter() and exit() cycles.
When it comes to keeping the state decoupled from the DOM in this case it is not the whole DOM state of the component that I need to synchronize in app-state but just the data to be rendered into DOM elements (as lists or SVG path points) and the state of user interaction with the component, e.g. user zoomed or panned the chart so I store the new zoom and pan values in app-state. When the component is re-rendered (e.g. coming back to a the page from another or in session transfer scenarios) I just transition to those app-state-retained values.
IMGUI (immediate mode graphics) is great for driving 2D canvas where some "smart canvas" calculates the diff from app state changes and where app state captures everything that is on the canvas, so applying the diff is applied rather than redrawing the whole canvas is a required optimization, and is a standard technique in game development.
If I make my D3 components spit out SVG path data rather than generate SVG and have an SVG-path-data-to-canvas convertor (not too hard, done that before) then a Virtual Canvas that does the diffing (in raster mode) and patches the current canvas would be great*.
So it seems like with D3 as the DOM reconciliation engine, I can build an IMGUI model without a Virtual DOM per se.
I never understood why someone would want to mix D3 and React in any non-shallow way, i.e. deep integration. It just means that they're having one DOM manager (or 'differ' if you prefer) inside another.
Obviously, this is a subtle subject so there are many opinions that may not make total sense, and I'm trying to understand why anyone would want to use React with D3 in any way other than a very shallow integration.
Help me understand if there is a rationale for that.
Thanks.
Marc