Fork me on GitHub

is there a way to prevent exceptions from breaking the React tree structure? E.g. when I make a (javascript) syntax error, say (.useSomeUnknownMethod obj) in a component definition this forces me to refresh the app. I would like to fix it and not having to refresh my browser


I’m guessing this could be done by wrapping the render method with a try/catch (but I would have to do monkey patch to do this globally, without introducing new mixins)


hmm. What behaviour would you expect? What happens in pure react?


I’ll rephrase: what exactly breaks so that you have to reload?


@tonsky So I’m editting my rendered application with figwheel and I introduce a runtime error in my view e.g. (.getasdfa data). I’m getting an error as expected:

edit.cljs?rel=1492721696559:393 Uncaught TypeError: data.getasdfa is not a function
    at Function.<anonymous> (edit.cljs?rel=1492721696559:393)
    at Function.cljs.core.apply.cljs$core$IFn$_invoke$arity$2 (core.cljs:3685)
    at cljs$core$apply (core.cljs:3676)
    at render (core.cljs?rel=1491307518599:130)
    at subscriptive.cljs?rel=1491911411675:48
    at Object.render (core.cljs?rel=1491307518599:83)
    at measureLifeCyclePerf (
    at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (
    at ReactCompositeComponentWrapper._renderValidatedComponent (
After fixing the introducted mistake, figwheel reloads, but the app doesn’t want to load the new code anymore until I do a full refresh of the app: Uncaught TypeError: Cannot read property 'getHostNode' of null
        at Object.getHostNode (
        at ReactCompositeComponentWrapper.getHostNode (
        at Object.getHostNode (
        at Object.updateChildren (
        at ReactDOMComponent._reconcilerUpdateChildren (
        at ReactDOMComponent._updateChildren (
        at ReactDOMComponent.updateChildren (
        at ReactDOMComponent._updateDOMChildren (
        at ReactDOMComponent.updateComponent (
        at ReactDOMComponent.receiveComponent (
I think it would be an improvement if the first exception didn’t break future code updates (via figwheel). I don’t understand the React internals enough (yet) to see how complicated this might be.


My work around now is to set an alert with the text “Uncaught fatal exception, check the logs and restart the app” whenever an error with “getHostNode” is being detected by window.onerror