请选择 进入手机版 | 继续访问电脑版

网络科技

    今日:274| 主题:272338
收藏本版
互联网、科技极客的综合动态。

[其他] Virtual DOM and me - it's complicated

[复制链接]
花落满茵席 发表于 2016-10-16 05:59:47
175 3

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
I have mixed feelings about virtual DOM. I get it: it’s cool, it’s different, it’s everywhere, it’s pure, it’s hipster. Thing is it’s not how the DOM works and that’s the issue for me.
  You see, DOM is mutable. If you want to have static layouts and switch between them virtual DOM is ok. That’s just not enough for me. I started with Flash in 1999 and I like interactions, animations, tailor-made components and nice little details. I also want to control what’s happening, when and how. Virtual DOM doesn’t let me do all that the way I want. It gets in the way.
  When you want to have some 3rd party component like Google Maps, things get even more complicated. You need some 4th party dependency to handle virtual DOM – mutable DOM conversion. Or be mutable and save the reference to the component, cross fingers and hope virtual DOM doesn’t mess things up.
  Also to prevent virtual DOM doing extra work, you need keys everywhere. In the mutable world you don’t need them, because things stay where you put them. And for example by saving references to a lookup table you can reorder really easily. You can even control which parts of the component are static and which not. With virtual DOM you need to do it with a hack (shouldComponentUpdate or whatever).
  What if you want to have a fadeout animation? What if another update comes before the transition ends? How would virtual DOM know where to put that element between the states? Yes, again there’s 3rd party dependencies, but you’ll end up with fatigue after some dozen of them. And if you want to have something more customized, you’re screwed. You don’t need to think those kind of things with the mutable DOM.
  You can even make pure updates with the mutable DOM if you want. Check out my tiny UI library    RE:DOMfor example. It doesn’t use virtual DOM. Still it’s super fast, easy to use and you can always rerender components if you want, but separate which parts are static and which dynamic. You can even use RE:DOM in the server, with    NO:DOM.  
  Virtual DOM might work for some, but it’s not for me. There, I’ve said it.



上一篇:细微处见功夫!聊聊那些不被重视的交互稿细节
下一篇:iPhone Storage Full? Free Up Space With These 18 Tips in iOS 10
时の熵 发表于 2016-10-16 07:57:19
顾客不是上帝,顾客只是上当。
回复 支持 反对

使用道具 举报

yhdg116 发表于 2016-11-21 06:02:07
我只想安静地做个美男子
回复 支持 反对

使用道具 举报

淚痕傾面難眠 发表于 2016-11-21 06:49:14
顶贴是一种态度!
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读


回页顶回复上一篇下一篇回列表
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )

© 2001-2017 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表