5 ms·
There's another advantage to virtual DOM: you can hot-swap code while developing and have React run its diff algorithm without reloading the page. If your compo
by danabramov 12y ago
There's another advantage to virtual DOM: you can hot-swap code while developing and have React run its diff algorithm without reloading the page. If your component has no (or little) side-effects, it means you get live reload as you edit for free. This is impossible with Backbone/jQuery soup of a view.
See my proof of concept video: https://vimeo.com/100010922 https://vimeo.com/100010922
And actually runnable example that you can edit without refresh: https://github.com/gaearon/react-hot-loader https://github.com/gaearon/react-hot-loader
I plan to write a blog post explaining how to integrate it into React project soon.
- dustingetz 12y agoYeah, the Om beginner tutorial demos this in lighttable with clojurescript, it's pretty epic. edit: https://github.com/swannodette/om/wiki/Basic-Tutorial https://github.com/swannodette/om/wiki/Basic-Tutorial
- danabramov 12y agoWhere can I take a look? In my case, this is pure JS, no Light Table or browser plugins needed. No messing with V8.
- swannodette 12y agoOm hot reload doesn't require Light Table or browser plugins, just eval support from your editor setup. There's no way to see this easily beyond going through the Om tutorial. But as you say this is just a benefit that more or less falls out of React if you're careful w/ state - Devcards is another ClojureScript example of the possibilities - http://rigsomelight.com/2014/06/03/devcards-taking-interactivity-to-the-next-level.html http://rigsomelight.com/2014/06/03/devcards-taking-interacti...
- lbotos 12y agoWhat editor are you using in that gif? Or is that just 10.10 that makes it look "cleaner"?
- danabramov 12y ago10.10, Sublime with Spacegray Light by Gadzhi Kharkharov
- superchink 12y agoOff-topic, but are you using the 10.10 DP as your daily OS? If so, would you mind sharing a quick note of your experience? Any show-stopping issues? Better/worse?
- danabramov 12y agoI am. It's less buggy than iOS 8 betas but it's somewhat rough if you're not used to living with beta software. Dock freezes twice a day, Safari's rendering is faster but app itself is quite slow. Personally I have high tolerance for this, but I know some folks would get frustrated quickly.
- notduncansmith 12y agoSo far I haven't noticed many setbacks with 10.10 (and I'm enjoying the new UI so far). Performance is good, every now and again software will refuse to install itself because it doesn't recognize my OS version. I can't remember the last time it crashed on me. Sublime is a little buggy, it'll go totally black for most of the screen, and I have to resize it to force a repaint, but that usually only happens when I have my desktop monitor plugged in (which is rare). Overall, it's been a really enjoyable experience - a stark contrast to the horribly buggy mess that is iOS 8.
- danabramov 12y agoUpdate: if you're interested, I blogged about how this works and how to integrate live reload in your project: http://gaearon.github.io/react-hot-loader/ http://gaearon.github.io/react-hot-loader/