In my opinion, it is important to first understand the problem.
I assume that you are dealing with some D3 functions that mutate the transferred data, for example d3-force , and the data is the state of your applications, for example, if you use Immutable.js with React and Redux.
The problem is that D3 has no way of knowing how to process Immutable.js data. Even if you find a way to get D3, it will not be a good idea, because it is not effective in the case of d3-force , when on each tick it will create a new immutable .
So, I suggest storing your state in a simple JavaScript array or object for interacting with D3.
For example, suppose you have a graph, and when you add a node, you send some action ( ADD_NODE ) to your store, and you may have a handler that updates your immutable state, such as reducers in Redux. You want to create another reducer that takes this node and returns plain [...nodes] . The same goes for other CRUD actions. This way your data will be synchronized. For example, if a user clicks on any of your nodes, you can get the source data for the index and all the D3 mutations saved.
Here is an example if you are using Redux. Hope this helps in collecting ideas.
const graphNodesReducer = (state = [], action) => { if (action.type in nodeTypes) { return [...state, action.payload]; // or [...state, action.payload.toJS()] if node is sent as immutable // or [...state, action.payload.get('label')] you can choose what to set } return state; }
source share