This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-17
Channels
- # beginners (69)
- # calva (25)
- # cider (12)
- # cljdoc (17)
- # cljs-dev (60)
- # clojure (67)
- # clojure-spec (2)
- # clojure-uk (17)
- # clojurescript (46)
- # cloverage (1)
- # code-reviews (6)
- # cursive (3)
- # datascript (8)
- # figwheel-main (1)
- # fulcro (13)
- # hyperfiddle (25)
- # off-topic (7)
- # re-frame (24)
- # reagent (12)
- # reitit (24)
- # ring (8)
- # spacemacs (11)
- # specter (22)
- # tools-deps (7)
- # unrepl (1)
is js/console.log
syntax future proof? as opposed to (.log js/console)
Rich himself started it back in 2011: https://github.com/clojure/clojurescript/commit/954e8529b1ec814f40af77d6035f90e93a9126ea#diff-a9cce52f0bf5a7b9afccbec54e4a0e4bR39
I've started seeing Cannot read property 'j' of null
errors in places where it doesn't make sense since upgrading to 1.10.439 from 339. e.g. the stacktrace leads me to the second line here:
(defmethod handle :tutorial/next [{:keys [state]} _]
(let [schedule (get-in state [:edit :tutorial :schedule])
any ideas what could be causing this?90% sure this coincided with the cljs upgrade
Does anybody know how can I add a static property or an extra method to a reagent component? Here is an example from the docs:
class HomeScreen extends React.Component {
static navigationOptions = {
title: 'Home',
};
/* render function, etc */
}
I need to declare a Component within the navigationOptions
property or method. How can I do that in Clojurescript + reagent? The third form does not give any result.Hey everyone, I’m just trying ClojureScript and figwheel and wondering if this is ok:
(event/listen (dom/get-element "test")
:blur
(fn []
(prn ":blur")))
This event handler doesn’t work when I run production build js.
But if I replace :blur
to “blur” it does.
So is it required? I am using advanced optimization.Event type should be a string anyway
Hey, are there any good resources on consuming clojure libs from clojurescript? I’m trying to use cljc
as much as possible. Specifically I’ve been working with loom (mixture) and ubergraph (java focus) as they both bring things to the table and I want to wrap up the complexities of dealing with them in a cljc
namespace.
@roman01la but keyword works in dev mode and I found it in examples here https://github.com/clojure/clojurescript/blob/master/samples/dom/src/dom/test.cljs
https://github.com/reagent-project/reagent/blob/master/doc/UsingSquareBracketsInsteadOfParens.md <-- is there a general pattern in clojure for putting functions inside square brackets, or is reagent an exception?
if you put a function in a vector in other contexts you will not get the result of the function, you will get a vector where the first element is a function
cljs.user=> (defn foo [x] [:div x])
#'cljs.user/foo
cljs.user=> [foo 1]
[#object[cljs$user$foo "function cljs$user$foo(x){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"div","div",(1057191632)),x], null);
}"] 1]
cljs.user=> (foo 1)
[:div 1]
The renderer is what does the [foo 1] magicWithout parens reagent would have to make use of macros. This vector trick helps to avoid that
@joebetz91 It's a useful pattern to describe functions and the args you want to pass them, and I've even used it in other langs, like javascript, before, but I don't think it's a pattern particular to clojure. Reagent makes particularly heave use of it, but it's a sometimes useful form of indirection in general
I can see how you'd want to delay evaluation of an expression to inspect or manipulate it, but then, isn't that what macros are for?
I've used it for e.g. things like building up functions to pass to a DB query builder from, say, query params passed to an API call
I'm having a peculiar problem (again). In the snippet you can see cljs and clj code that work perfectly fine when running in dev mode (figwheel-main). As soon as I make a prod build via uberjar (and simple optimizations), nothing is sent via POST. The handler is still called but whithout data. I'm at a loss. Any tips on how to debug this or hints what this could be are greatly appreciated!
The console logs show data in dev mode, but the form data seems to not have anything in it in a prod build.
did you verify from the client-side that nothing is sent? via e.g. dev tools or by trying the same POST from curl? Might help narrow it down to a client or server issue
I just this moment realized that the form data might not be empty but just looks like it. I have to dive deeper into the dev tools I think (no experience looking at js objects and the like in the dev console so far).
there's a wrap-multipart-params
in there you can use around your /upload
handler that should parse it for you
That sounds like it might be the culprit! I stumbled over this when I figured out compojure routes, but I read somewhere that compojure does this automatically. I wonder why it works in a dev build after all. But I just found the place where I can see whether it's at least sent correctly and I'm doing another prod build right now.
yeah that's a silly thing to add for you in dev, better to catch such an omission early. I'm also curious as to why it did that
That is the part that's strangest to me: I've been using the code for a month now locally 🙂
not sure, tbh - it's possible the server it provides has some default middleware wrappers I guess
@johb.maier ahhh I bet it's this - specifically the ring-defaults
it's referring to https://figwheel.org/docs/ring-handler.html#the-last-handler
@jesse.wertheim Yes, I bet! It's been a long time since I've added the handler... I forgot about that. I even remember having read it now
I guess a good takeaway is to write separate tests for the server that make API calls against it directly (or just testing the handlers via ring test tools) rather than via figwheel
The funny thing is: I'm in the process of trying to switch to or at least trying out shadow-cljs. I just wanted to get the prod build running before doing so. In hindsight the other direction would have been better since I'd probably have caught that 🙂
@jesse.wertheim Yes that's a todo as well! It's a learning project 🙂