Fork me on GitHub
#shadow-cljs
<
2019-08-24
>
Stefan12:08:32

I have some time for my react native app again. All the spikes are pretty much done, I’m starting the actual app now. So I’m starting from scratch with a new react native app. I make the minimal modifications to use CLJS and hot loading with shadow, the same ones as before, and guess what: it doesn’t work 😞 I’ve been looking at docs, forums, zulip, cannot find a solution. What am I doing wrong?

(ns app.core
  (:require [reagent.core :as r :refer [atom]]
            ["react-native" :as rn :refer [AppRegistry, Platform]]))

(defn app-root []
  [:> rn/View
   [:> rn/Text "First line"]
   #_[:> rn/Text "------------------"]
   [:> rn/Text "Second line"]
   [:> rn/Text "Hi!!!!"]])

(defonce app-root-ref (atom nil))

(def updatable-app-root
  (with-meta app-root
    {:component-did-mount
     (fn [this]
       (println "did mount")
       (reset! app-root-ref ^js this))}))

(defn init []
  (.registerComponent AppRegistry
                      "Han"
                      #(r/reactify-component updatable-app-root)))

(defn reload {:dev/after-load true} []
  (.forceUpdate ^js @app-root-ref))
The only real difference with before that I can think of, is that I’m using RN 0.60 now.

Stefan12:08:17

Oh wait that method apparently only works when changing children of app-root, not on app-root itself.

Stefan12:08:21

Accidental complexity 😞