Fork me on GitHub
#helix
<
2022-08-18
>
Evan Z02:08:44

@lilactown as long as I have you, I’m quite new to clojurescript development and am curious if I should expect that reloading toplevel definitions in the REPL should change content on the page dynamically

lilactown02:08:16

you have to set that up. are you using the fast refresh feature of helix?

Evan Z02:08:28

I’m trying to but not sure how to verify. I’m a bit confused by how that works. Does that retain state across refreshes or across redefinitions?

Evan Z02:08:43

oh I missed this lib.cljc guy that seems to do some redefinition of defnc

Evan Z02:08:54

I was wondering how this component flag gets injected.

lilactown02:08:39

yeah, it's kind of awkward rn. you have to define your own defnc macro

lilactown02:08:40

react-refresh ought to refresh all of the components in the namespace you change, and retain any state unless you've changed the hooks used inside it

lilactown02:08:05

if you don't care for it, you can always do this:

(ns my-app.core
  (:require
   ["react-dom" :as rdom]
   [helix.core :refer [$ defnc])

(defnc my-app
  []
  "hello")

(def root (rdom/createRoot (js/document.getElementById "app"))

(defn ^:dev/after-load start!
  []
  (.render root ($ my-app))

lilactown02:08:51

react 18 syntax above. if you're using react 17 or earlier, you can just call rdom/render in start!

lilactown02:08:29

just released helix 0.1.8 with the fix for that infinite loop