I think I'm seeing intermittent behaviour with Krell and asset js/require. With an initially working example, a simple code change and recompile results in an empty Krell_assets.js
Deps.edn:
{:deps {io.vouch/krell {:git/url "<https://github.com/vouch-opensource/krell.git>"
:sha "9c88f29fcc25780238914ad52f266c349c2bd787"}
io.vouch/reagent-react-native {:git/url "<https://github.com/vouch-opensource/reagent-react-native.git>"
:sha "54bf52788ab051920ed7641f386177374419e847"}
reagent {:mvn/version "1.0.0-alpha1"
:exclusions [cljsjs/react cljsjs/react-dom]}}}
core.cljs:
(ns krell-project.core
(:require [react :as react]
[reagent.core :as r]
[reagent.react-native :as rn]
[react-native-reanimated :as re-module]
[react-native-gesture-handler :as rg]))
(def re (.-default re-module))
(def animated-view
(r/adapt-react-class (.-View re)))
(defn ^:export -main [& args]
(r/as-element
[rn/view {:style {:flex 1}}
[rn/view {:style {:flex 1 :align-items "center" :justify-content "center"}}
[animated-view
[rn/image {:source (js/require "../../resources/img/card1.png")
:style {:width 300 :height 200 :borderRadius 18}}]
]
[rn/text "Hello"]
]
]))
Krell_assets.js:
module.exports = {
assets: {
}
};
When I delete target/
and .cpcache/
and clj -m krell.main -co build.edn -c -r
all works as expected - Krell_assets.js:
module.exports = {
assets: {
"../resources/img/card1.png": require('../resources/img/card1.png') }
};
@admarrs yes that's a known issue, working on it
@dnolen ok, thanks
Krell master has a fix for asset/requires, some of you may have noticed breakage after a recompile - the big problem should be fixed - there may be edge case still - minimal repros would help
If you're going to try master, remove .cpcache
, remove your :output-dir
, and make sure you're not specifying a ClojureScript version - Krell is back on ClojureScript master for now
I'm trying to move from re-natal to Krell on a medium-ish application so it's getting a real-world spin right now
@dnolen that's great. On your medium-is application how are you managing state? Playing with the simple reagent example Ratom doesn't seem to trigger a re-render, I guess because of the wrapping r/as-element.
@admarrs in the app I'm porting we're using re-frame
@admarrs don't follow the tutorial for tips on how to use Reagent, I'm not a Reagent expert - if that's wrong I can fix it
@admarrs I looked into this a bit, it's because Ratom is a bit magical
it needs to be executed in a context that Reagent controls
so if you add some indirection (r/as-element [my-fn])
and only put Ratom stuff "beneath" my-fn
it will work
@admarrs I've updated the tutorial - it's a simple thing to stumble over
in fact ran into in the app I was porting and couldn't figure it out w/o reading Reagent source
adding some clarifying text as well