Fork me on GitHub
#helix
<
2022-06-13
>
lilactown15:06:34

you can use helix.hooks/use-state with JS data

lilactown15:06:28

for error boundaries, you can use helix.core/defcomponent but it’s not super well documented

geraldodev19:06:42

I'll try that, if it makes better error catching.

lilactown19:06:39

here's a "simple" example:

(defcomponent error-boundary
  (constructor
    [this]
    (set! (.-state this) #js {:error nil}))

  ^:static
  (getDerivedStateFromError
    [this error]
    #js {:error error})

  (render
    [this props state]
    (if-let [error (.-error ^js state)]
      (if (:on-error-component props)
        ($ (:on-error-component props))
        (d/div (pr-str error)))
      (:children props))))

👍 1