Fork me on GitHub
#cljsrn
<
2020-04-30
>
admarrs11:04:38

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

admarrs11:04:56

{:deps {io.vouch/krell {:git/url ""
                        :sha "9c88f29fcc25780238914ad52f266c349c2bd787"}
        io.vouch/reagent-react-native {:git/url ""
                                       :sha "54bf52788ab051920ed7641f386177374419e847"}
        reagent {:mvn/version "1.0.0-alpha1"
                 :exclusions [cljsjs/react cljsjs/react-dom]}}}

admarrs11:04:17

core.cljs:

admarrs11:04:26

(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"]
      ]
    ]))

admarrs11:04:46

Krell_assets.js:

admarrs11:04:53

module.exports = {
  assets: {
  }
};

admarrs11:04:01

When I delete target/ and .cpcache/ and clj -m krell.main -co build.edn -c -r all works as expected - Krell_assets.js:

admarrs11:04:16

module.exports = {
  assets: {
    "../resources/img/card1.png": require('../resources/img/card1.png')  }
};

dnolen12:04:03

@admarrs yes that's a known issue, working on it

dnolen17:04:13

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

dnolen17:04:15

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

dnolen17:04:24

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

👍 2
admarrs17:04:44

@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.

dnolen17:04:26

@admarrs in the app I'm porting we're using re-frame

dnolen17:04:46

@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

dnolen19:04:42

@admarrs I looked into this a bit, it's because Ratom is a bit magical

dnolen19:04:50

it needs to be executed in a context that Reagent controls

dnolen19:04:13

so if you add some indirection (r/as-element [my-fn])

dnolen19:04:27

and only put Ratom stuff "beneath" my-fn it will work

dnolen19:04:26

@admarrs I've updated the tutorial - it's a simple thing to stumble over

dnolen19:04:48

in fact ran into in the app I was porting and couldn't figure it out w/o reading Reagent source

dnolen19:04:21

adding some clarifying text as well