简体   繁体   中英

D3js and React regarding DOM manipulations

How does D3 dom-manipulation mechanism influence (if any at all) on React's virtual-dom?

I've found many examples show that both libraries can work together great, but none of them refer to this issue.. It might not be an issue at all btw, it's just a big question that I raised, but couldn't find an answer for.

EDIT:

I've just learned that only when "writing" to the virtual-dom, the dom get's updated. and ALWAYS when "reading" from the actual "reading" is done on the virtual-dom.

So when I use D3 to update the DOM directly, the virtual-dom has no idea about it, and I won't be able to read the new changes from the virtual-dom. That's what I was afraid of, and now I wonder how React's helping me when I have to use D3?

You follow the rules of each when interacting with them. With regard to react, you wrap the d3 dom manipulation in a component, and that's it.

Depending on the components you use, you can either have components that do everything in d3, or write some primitives which allow you to use react components instead of low level d3.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM