Fork me on GitHub
#clojurescript
<
2019-09-16
>
sova-soars-the-sora01:09:56

hi, i'm trying to create multiple javascript files. i have multiple cljs files. is there something i should know about :cljsbuild in project.clj ?

sova-soars-the-sora01:09:02

I try doing lein cljsbuild particle and i have a build :id particle

sova-soars-the-sora01:09:20

Oh, subtasks are different than build IDs

sova-soars-the-sora01:09:50

nevermind i didn't have to do anything

sova-soars-the-sora02:09:18

spoke too soon: Uncaught ReferenceError: goog is not defined

plexus06:09:32

@sova you're gonna have to give more context for people to be able to help you. What does your compiler configuration look like? What command are you using? Are there any warnings or errors during compilation? Are you targeting a browser or something else?

plexus06:09:36

My guess would be your :asset-path is wrong. Check in your dev tools in the network tab if you are getting 404s

tomaas08:09:02

hi, im using firebase from cljsjs, and after building for production either with optimization :advanced or :simple, im getting TypeError: firebase.$h is not a function. I remember it worked well when i was only using firebase's auth, but now using firestore as wel as storage it started failing with this error. What am i missing?

roman01la08:09:53

I’d say you have to check that APIs that you are using are actually covered by externs

roman01la08:09:13

also set :infer-externs true in compiler options

roman01la08:09:46

and put (set! *warn-on-infer* true) in the beginning of ns where you interop with firebase library, so compiler will print warnings if it’s unable to infer externs

tomaas08:09:23

great, thank you

tomaas08:09:51

(-> (js/firebase.storage) (.ref) (.child (str "stuff/" user-uid)) (.put image) (.then (fn [snapshot] )))

tomaas08:09:16

im interoping it this way. It's correct isn't?

roman01la08:09:29

yep looks good

tomaas09:09:15

@U0FR82FU1, wow, i was missing :infer-externs true in my cljsbuild config. How did it then work with firebase auth without this option? 🙂

roman01la09:09:06

because cljsjs firebase includes externs

roman01la09:09:36

infer-externs is to infer externs by the compiler

tomaas09:09:33

yeah, but now with this option, after compiling for production everything works (firestore, storage..). Before, without the option, only auth worked. This is what I don't get

roman01la10:09:08

that means that externs file in firebase package only describes auth part of the library and externs inference is able to infer missing externs

tomaas10:09:12

nice, thank you very much @U0FR82FU1

Michael08:09:38

hello, anybody knows what is the last version of clojure to support java 7?

tomaas08:09:36

hi, better ask this in #clojure

✔️ 4
Michael08:09:13

oops yeah sorry wrong tab :S

andy.fingerhut08:09:33

Clojure 1.9 should be the latest version that supports Java 7. According to the change log, Clojure 1.10 is the first version that mentions requiring Java 8: https://github.com/clojure/clojure/blob/master/changes.md

alpox17:09:34

Did anyone here use hx and had a problem using React.memo?

lilactown17:09:03

@alpox the docs are slightly misleading - don’t use (react/memo =)

lilactown17:09:36

you should use a function that will check the specific props you want to compare

alpox17:09:02

I have the rather special case that the component generated by React.memo has to be passed as child to another component - but it should not be rendered while doing so. The error I get is Unknown element type #object[Object] found while parsing hiccup form: [object Object] I know the part about not using (react/memo =) as I was skimming through the issues 🙂

alpox17:09:16

{:wrap [(react/memo (fn [a b] (= (->clj a) (->clj b))))]} Is what I do (Using cljs-bean)

lilactown17:09:12

if you take the wrap away, it works?

alpox17:09:20

Yes it does

alpox17:09:27

If I just remove this line it works all fine

alpox17:09:36

(Except for the performance issues 😄 )

alpox17:09:07

I believe it must be an issue with the usage of the memoized component

alpox17:09:04

It is passed as a child to https://react-window.now.sh/#/api/FixedSizeList Where we have the special case of using the component as something like: <List>{Component}</List> instead of directly rendering it by <List><Component /></List>

alpox17:09:50

So when I use the hiccup: [FixedSizeList {...} MemoizedComponent] i get the error shown above - but only if the memo is applied

lilactown17:09:36

can you try just rendering the memoized component real quick? that error doesn’t make sense given what I see so far

lilactown17:09:44

(without the FixedSizeList)

alpox17:09:20

Works fine

alpox17:09:58

[ClipListItem {:index 0
                    :style {:height "50px"
                            :background-color "blue"}
                    :data {:clips [{:text "foo" :_id "bar" :time (.local DateTime)}]
                           :is-item-loaded? (constantly true)
                           :selected? selected?
                           :toggle-selected toggle-selected}}]
Renders as expected

alpox17:09:06

@lilactown When I print out ClipListItem to the console without the memo I get: myclipse$clip$views$ClipListItem[props maybe-ref] and with memo I get {$$typeof: Symbol(react.memo), type: ƒ, compare: ƒ} there might be something about this?

alpox18:09:10

Sadly I have only a few minutes left today to look into this. It is not so pressing as its a personal sideproject though. I was just wondering if you or someone else would know about this issue @lilactown 🙂 Maybe I'll find a workaround another time

lilactown18:09:08

very strange. I’ll see if I can repro it later. thanks for your patience!

alpox18:09:18

@lilactown Thank you for your time as well!

alpox21:09:14

@lilactown I think I tracked it down to the hiccup interpretation of hx:

#?(:clj Object
     :cljs default)
  (-as-element [el config]
    (cond
      ((:is-element? config) el) el

      :default
      (throw
       (ex (str "Unknown element type " (pr-str (type el))
                " found while parsing hiccup form: "
                (.toString el)))))))
As a component itself is no react element, this does not allow to pass an unrendered component as a child to a component like react-window wants you to and throws an Unknown element type error instead.

alpox21:09:14

The is-element? seems to use https://reactjs.org/docs/react-api.html#isvalidelement which returns false for components themselves but true for generated elements (Component instances)

lilactown21:09:30

yeah, I’m a bit confused why it would fail that because it’s not actually in a hiccup form

lilactown21:09:14

actually nvm, that makes sense

lilactown21:09:40

I guess if we assume that children can be anything then I should remove that check

alpox21:09:26

I'm not sure if its good practice to do that but I believe that react allows anything to be passed. Here it kind of makes sense as usually, the child would be a function (Which is a known pattern) but when you memoize the child function, what you get is a component

alpox21:09:08

I guess it would be either letting the user pass anything - or handle this specific case. I don't know what is better 😄

lilactown21:09:47

I think it’s best to simply remove it

lilactown21:09:03

if it’s unrenderable, then React will give an error

lilactown21:09:22

PRs welcome 😄 otherwise I’ll try and get to fixing it sometime this week

alpox21:09:35

That is true. Also, this would allow to use all kind of weird react libraries however they are implemented 😄

alpox21:09:25

I can give it a shot when I find the time, not sure when that will be 😄 this week i'll be quite busy travelling