Fork me on GitHub
Alexander Moskvichev06:06:46

Hi. Trying to start example, but got an error Cannot read property 'createElement' of undefined... React exists in node_modules folder. I'm finding a way to add js code to a reagent project.


you are likely importing react incorrectly, should be import * as React from "react".


commonjs -> ESM interop is in a weird place. wouldn't really recommend it too much currently.

Alexander Moskvichev08:06:58

import * as React from 'react' did the trick, thank you. Should I create a PR on github?

Phil Hunt07:06:26

Hi. Has anyone got suggestions for introductory hands-on Clojurescript material. Recent enough that it's not going to collapse in a muddle of broken dependencies and with enough context that you don't have to be thoroughly conversant with the modern JS ecosystem to know what's going on?


@roman01la @lilactown Apparently I failed to convey that I'm looking for something that's slightly more XPath-like and allows for the selection of nodes (e.g. select all child nodes that are of a certain element type).

Roman Liutikov08:06:17

I'd say just do it:tm: via interop then, document.querySelector is already good and afaik there's xpath dom api

๐Ÿ‘ 3

@phil634 I'm not entirely sure what you are after, but perhaps use re-frame-template to get a scaffold? We maintain it with very recent dependencies.

Phil Hunt10:06:55

Thanks Mike. That looks very helpful


Is that what you are after?


to try the code at I created the project with

lein new figwheel cljs-weather -- --reagent
added the code and dependencies, and then ran
then opened the project in emacs, where I ran
and the project opened in my browser. I can evaluate simple forms in core.cljs like (+ 1 1) with cider-eval-defun-at-point but trying to evaluate the ns form or, trying to get data from the web with (GET <some url>) causes me to get
Caused by java.lang.RuntimeException
   Unable to resolve symbol: GET in this context
so, what do I have to do to be able to evaluate forms in my buffer as with clj in a cljs project?


(posted in #cider, too)


@patrickanium looks like you are evaling in the CLJ REPL since that is a CLJ error. I don't know how to switch your cider session to CLJS though.


I got a problem with metadata attached to a function

(defn make [] ^:matcher? (fn [x] x))

(meta (make))
this code works in clojure but throws ERROR - Unexpected token 'return' in clojurescript am I missing something and this behavior is documented somewhere?


(function() {
    cljs.user.make = (function cljs$user$make() {
        return cljs.core.with_meta(
            return (function(x) {
                return x;
            });, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null, "matcher?", "matcher?", (1159196681)), true], null));
    return (
        new cljs.core.Var(function() {
            return cljs.user.make;
        }, new cljs.core.Symbol("cljs.user", "make", "cljs.user/make", (2103882579), null), cljs.core.PersistentHashMap.fromArrays([new cljs.core.Keyword(null, "ns", "ns", (441598760)), new cljs.core.Keyword(null, "name", "name", (1843675177)), new cljs.core.Keyword(null, "file", "file", (-1269645878)), new cljs.core.Keyword(null, "end-column", "end-column", (1425389514)), new cljs.core.Keyword(null, "column", "column", (2078222095)), new cljs.core.Keyword(null, "line", "line", (212345235)), new cljs.core.Keyword(null, "end-line", "end-line", (1837326455)), new cljs.core.Keyword(null, "arglists", "arglists", (1661989754)), new cljs.core.Keyword(null, "doc", "doc", (1913296891)), new cljs.core.Keyword(null, "test", "test", (577538877))], [new cljs.core.Symbol(null, "cljs.user", "cljs.user", (877795071), null), new cljs.core.Symbol(null, "make", "make", (356488202), null), null, (11), (1), (1), (1), cljs.core.list(cljs.core.PersistentVector.EMPTY), null, (cljs.core.truth_(cljs.user.make) ? cljs.user.make.cljs$lang$test : null)])));
here is generate javascript. on 4th line there is extra return statement


however this code works as expected

(defn make [] (with-meta (fn [x] x) {:matcher? true}))

(meta (make))


looks like a bug, post it to so it doesn't get lost in the slack void

๐Ÿ‘ 8

Hi(newbie here)!! is there a lightweight json lib for cljs (frontend) like cheshire (for clj) or do people use some js-wrapped lib most of the time please?

Chris McCormick12:06:14

(js/JSON.stringify (clj->js some-data-structure)) to serialize and (js/JSON.parse some-json-string) to deserialize might be good enough for what you want to do.


cool thanks @chris358 do you know if there are some ways to keywordize the clj datastructure in this case ? or do i have to do it manually


oh yeah my bad I think there is an option...just stumbled upon it on the doc


@delaguardo yeah an old bug, nobody's ever offered a patch for that probably because it's not that critical of a pattern, patch+test welcome


(well that and some kind of workaround)


does anyone maintain a list of react wrappers for clojurescript?


I guess this is the best place, but it's out of date. I'm going to add Helix and Hicada. Anything else I should add?


hx is a precursor to helix (we use hx)


I didn't add hx since it's superseded by helix. uix looks very nice! Feels like reagent but with nice support for hooks.


what's the recommended way to emit a #js {} or #js [] from a macro? I'm guessing (cljs.core/js-obj) / (cljs.core/array)? would these compile down to literals eventually?


@plexus cljs.tagged-literals/JSValue also works


(defmacro thing [] (let [foo (JSValue. [1 2 3])] `(hello-world ~foo)))


oh nice, didn't know that one


I love the simplicity of setting up a new project with Next.js. What is the ClojureScript equivalent?


ClojureScript has "templates" which will create you a scaffold. Eg. re-frame-template or Luminus.


Thanks @U051MTYAB, this was really helpful!


I've used and it was really neat. (disclaimer: I have no idea what next.js is)

๐Ÿ‘ 4
๐Ÿ‘ 4

@dnolen you once had cljs performance demo/test thing on the web that showed a huge grid of squares updating to show dom change speed (I think)... do you remember what that was or where it is?


itโ€™s probably or one of the other links from that blog


@patrickanium to be clear that wasn't about dom change speed at all


just the number of core.async loops in the browser


it was... cool.


oh that one sorry


that one was different, forgot about that one - the point of that one was different


still not about dom performance ๐Ÿ™‚


rather using core.async to batch dom updates so a text field doesn't become unresponsive


haha so many posts... was looking for it but can't find it...


honestly, was really just into the cool effect of the ui.


but now wanting to update a grid like that with websocket data from a MIDI source, so it came to mind.


I need to be at your kitchen table thing, lol.


Is it possible to combine modules ( and the new bundle target?


I think that you will only use bundle case its a lib and only use modules case its a final app