mirror of https://github.com/status-im/reagent.git
Don't catch exceptions in render
This commit is contained in:
parent
ea021d3b87
commit
4ccec97274
|
@ -107,24 +107,23 @@
|
|||
(defn clear-container [node]
|
||||
;; If render throws, React may get confused, and throw on
|
||||
;; unmount as well, so try to force React to start over.
|
||||
(try
|
||||
(.! node :innerHTML "")
|
||||
(catch :default e
|
||||
(do (warn "Error unmounting:")
|
||||
(log e)))))
|
||||
(some-> node
|
||||
(.! :innerHTML "")))
|
||||
|
||||
(defn render-component [comp container callback]
|
||||
(let [rendered (volatile! nil)]
|
||||
(try
|
||||
(binding [*always-update* true]
|
||||
(.' js/React render (comp) container
|
||||
(->> (.' js/React render (comp) container
|
||||
(fn []
|
||||
(binding [*always-update* false]
|
||||
(swap! roots assoc container [comp container])
|
||||
(if (some? callback)
|
||||
(callback))))))
|
||||
(catch :default e
|
||||
(do (clear-container container)
|
||||
(throw e)))))
|
||||
(callback)))))
|
||||
(vreset! rendered)))
|
||||
(finally
|
||||
(when-not @rendered
|
||||
(clear-container container))))))
|
||||
|
||||
(defn re-render-component [comp container]
|
||||
(render-component comp container nil))
|
||||
|
|
Loading…
Reference in New Issue