Fork me on GitHub
#cljsrn
<
2019-10-03
>
kacgrzes21:10:58

Hello everybody! Today I created RN 0.61.2 project and setup shadow-cljs to run clojurescript. I disabled fast refresh / live reload on RN side and wanted to go with clojure HMR system. When I run shadow-cljs watch app, clojurescript code compiles well, but I still have to reload my ios simulator by hand. Do you know how to enable that? Can I use figwheel with shadow-cljs? Is that even necessary? My shadow-cljs.edn file looks like this:

;; shadow-cljs configuration
{:source-paths
 ["cljs"]

 :dependencies
 [[reagent "0.8.1"]]

 :builds
 {:app
  {:target :react-native
   :init-fn hello.core/init
   :output-dir "app"
   :devtools {:autoload true}}}}
EDIT: I managed to run after-load function and alert works just fine, it re-runs each time I change my code, but rendered react component on the ios simulator stays the same. Do you have any ideas on how can i re-register app component or do something to reload RN component? Here is my code:
(defn alert [title]
  (.alert (.-Alert react-native) title))

defn start
  {:dev/after-load true}
  []
  (alert "Hello World!")
  (.registerComponent app-registry "TestApp" #(r/reactify-component app-root)))

(defn init []
  (start))

Michaël Salihi06:10:39

@UFD5H42HG You should use a render function like this to get hot-reload handle by Shadow-cljs https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L36-L59

kacgrzes07:10:31

This is awesome! Thank you @UFBL6R4P3

👌 1
thheller08:10:52

yeah the registerComponent thing can only be called once so you need a helper like that to make it work

👍 2
jgood23:10:30

@thheller So I implemented jest based off the PR you linked the other day. For a basic test with no imports it works as expected. However, when I include some of the namespaces I want to test it only works when I compile with shadow-cljs release test. When compiling with shadow-cljs watch test the yarn jest errors out with a heap limit error.

jgood23:10:29

I've increased the heap limit but it still happens with 4GB allocated.