Fork me on GitHub
#clojurescript
<
2020-08-05
>
dnolen00:08:32

@quoll I can't remember how that ended up in Clojure, @alexmiller would know - if it's intentional then that fix just hasn't been ported over

quoll00:08:56

I wasn’t sure if I could look in a transient map, but it appears that I can. I’ve been doing some testing on it, and it’s reliable for large numbers of keys (both Clojure and ClojureScript). (Yes, I know I need to look at the sources and not rely on empirical testing) But the transient approach is certainly faster for loading a lot into the map, so that’s why I’m trying to stick with it.

Alex Miller (Clojure team)01:08:29

that was CLJ-700 which was fixed in 1.9, iirc

👍 3
quoll00:08:24

OK, thank you

Jason00:08:49

i'm trying to translate material-ui js samples to cljs as a first time front end writer https://material-ui.com/components/buttons/#buttons-with-icons-and-label say:

<Button
        variant="contained"
        color="secondary"
        className={classes.button}
        startIcon={<DeleteIcon />}
      >
        Delete
      </Button>
and my best guess cljs equivalent is:
(defn add-thing-button [{:keys [^js classes]}]
  (fn []
    [:> Button {:classes (.-button classes)
                :variant    "contained"
                :color      "primary"
                :on-click   #(rf/dispatch [:add-thing/open-dialog])
                :startIcon icons/Add    ;; <- refuses to render
                }

     "Add Thing"]))

(defn add-thing-button-widget [kv]
  [:> (with-styles
        (reagent/reactify-component
         (add-thing-buton kv)))])
The :startIcon refuses to render no matter how i package it. What noob error am I making? Any help appreciated

hlolli00:08:51

r/as-element or better :startIcon [:> icons/Add] you see here that <DeleteIcon /> is an instance of element but not symbol of class/function-component.

Jason01:08:27

thanks for the reply. when i try :startIcon [:> icons/Add]i get a blank page but no errors in the console.

hlolli01:08:12

sorry, Im bit rusty, it's a prop so it wont be passed trough to reagent directly, you'll need to call some reagent function on this. I recommend reading the interop parts of the reagent documentation https://cljdoc.org/d/reagent/reagent/1.0.0-alpha2/doc/tutorials/interop-with-react

Jason01:08:58

no worries, thanks for taking the time to reply

cljs 3
Oliver George01:08:09

r/as-element sounds right to me

Jason01:08:10

after reading the linked doc and sample, create-element turned out to be the answer. Thanks all

Shako Farhad14:08:36

Does anyone have any experience with the new Web Animations API? How do you use it with reagent, or re-frame, or at all? ^^ https://web.dev/web-animations/

andrea.crotti14:08:02

uhm weird I'm trying to use the cljs-ajax library in a cljs file, and the same exact code works fine in CLJ but doesn't do anything in CLJS, simply returning this but never actually calling the handler function

#object[Object [object Object]]

andrea.crotti15:08:12

ah right it's just

has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I should have checked the console before

quoll17:08:40

I’m late to the party, but I wanted to say… I haven’t looked at Quick-Start for a while, and just went through it now. I’ve been working with ClojureScript command line repls for a while, but I am blown away at how smooth and easy it is now. I’m not sure who else was involved, but I can see it was documented by @dnolen. Thank you!

👍 6
dnolen20:08:17

@quoll there's a good amount of feedback about it so the credit goes to everyone that tried it out

👍 3
dnolen20:08:42

that said, it was driven driven by finally losing patience with all the scripting to do the most basic things

👍 6
dnolen20:08:20

the CLI stuff was all designed to address that and simply adopt Clojure conventions

quoll20:08:25

which is why I love it 🙂

borkdude21:08:53

I love it too.

zackteo23:08:56

Am reading the clojurescript FAQ for JS devs and saw "You can also write functions in ClojureScript and call them from JavaScript." Was just wondering, is there a good way to incrementally convert a JS codebase to Clojurescript? Or must it be a complete overhaul? :o

noisesmith23:08:33

@zackteo you can create a "helper" namespace in cljs, and pull it into your js module

noisesmith23:08:51

migrate functions one by one into the helper, until the helper replaces the thing that uses it

noisesmith23:08:51

you should be able to move one fn at a time, and you might not even need to rewrite any tests :D