Skip to content

Commit

Permalink
Workaround for facebook/react#2461
Browse files Browse the repository at this point in the history
If a component's render function throws an error, React cannot recover. This causes subsequent hot reloads to fail. Now we catch these errors during hot reloading so things are moar better.
  • Loading branch information
dmohs committed Aug 7, 2015
1 parent d49e015 commit 853777e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A ClojureScript wrapper for React.
### Add dependency:

```clj
[dmohs/react "0.2.4"]
[dmohs/react "0.2.6"]
```

## Top-Level API
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(def build-dir (or (System/getenv "BUILD_DIR") (throw (Exception. "BUILD_DIR is not defined"))))


(defproject dmohs/react "0.2.5"
(defproject dmohs/react "0.2.6"
:description "A ClojureScript wrapper for React."
:license "http://opensource.org/licenses/MIT"
:url "https://github.com/dmohs/react-cljs"
Expand Down
8 changes: 7 additions & 1 deletion src/dmohs/react/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@
(fn []
(this-as
this
(let [rendered (render (default-arg-map this))]
(let [rendered (if @hot-reloading?
(try (render (default-arg-map this))
(catch js/Object e
(.log js/window.console (.-stack e))
(create-element :div {:style {:color "red"}}
"Render failed. See console for details.")))
(render (default-arg-map this)))]
(if (vector? rendered)
(apply create-element rendered)
rendered))))
Expand Down

0 comments on commit 853777e

Please sign in to comment.