Why does $ use &, rather than merge?
Dunno, I am constantly tripping over it even as we speak 🙂 core.cljs:5383 Uncaught Error: No item & in vector of length 2
I really have no way how to debug this
I am baffled. I know what the problem is, but I don't know how to solve it in a general way, without using empirical programming.
ok, so I actually have to do a merge externally and then spread the merge
I think that will work, but I am getting the feeling that there is a better way to do it : )
Hmm interesting.
the reason being that sometimes what I want to merge is null, and it throws
what should I do if I want to document my components?
@dominicm it’s to allow some perf enhancements at macro time
@lilactown could the same performance be achieved by a fn that takes a cljs map and a list of maps and has a return hint set as js obj?
I’m not sure what that would achieve yet
($ {:foo "bar" :baz 123})
macroexapnds to (.createElement react #js {:foo "bar" :baz 123})
$
will rewrite a map in the first position. if it’s not a map literal, it can’t distinguish between props and an arbitrary expression that returns a react element
($ foo bar)
is ambiguous, so it requires runtime checks.
($ (foo {:bar "baz"}))
is also ambiguous
I see what you’re saying, maybe you could add some special type hinting. but it couldn’t be ^js
, since a React Element is also a POJO
you can add docstrings to components
I think I will try a custom macro that doesn't try to guess but requires explicit arguments
like ($$ (can-return-stringforelement-or-component) (can-return-hash-or-nil-for-props))), children is part of props anyway, I have no problem having to pass them explicitly as such
in fact, instead of nil i would do a default {children:[]} for good measures and composability 🙂
another thing I just realized, while in cljs I can use strings as keys for hashmaps, I can't always do the same for components
Possible feature idea: ($ "div.foo.bar")
to reclaim some glorious reagent convenience.
that's the same as className="foo bar" ?
i never used reagent
Yeah.
well, my classnames are mostly defined dynamically or pre-defined anyway. no one should write classnames by hand 🙂 I should know, I was a site-builder for 7 years