Hacker News new | ask | show | jobs
by danabramov 4352 days 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

And actually runnable example that you can edit without refresh: https://github.com/gaearon/react-hot-loader

I plan to write a blog post explaining how to integrate it into React project soon.

2 comments

Yeah, the Om beginner tutorial demos this in lighttable with clojurescript, it's pretty epic.

edit: https://github.com/swannodette/om/wiki/Basic-Tutorial

Where can I take a look? In my case, this is pure JS, no Light Table or browser plugins needed. No messing with V8.
Om 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-interacti...
What editor are you using in that gif? Or is that just 10.10 that makes it look "cleaner"?
10.10, Sublime with Spacegray Light by Gadzhi Kharkharov
Off-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?
So 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.

I 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.