This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-09
Channels
- # babashka (63)
- # beginners (97)
- # biff (11)
- # chlorine-clover (5)
- # cider (46)
- # clara (2)
- # clj-kondo (34)
- # clojure (65)
- # clojure-austin (1)
- # clojure-europe (9)
- # clojure-france (10)
- # clojure-italy (11)
- # clojure-nl (3)
- # clojure-spec (29)
- # clojure-uk (5)
- # clojuredesign-podcast (1)
- # clojurescript (56)
- # clr (6)
- # component (17)
- # conjure (5)
- # core-typed (5)
- # cursive (23)
- # data-science (5)
- # datahike (3)
- # dirac (3)
- # emacs (20)
- # fulcro (17)
- # graalvm (10)
- # graphql (8)
- # helix (99)
- # honeysql (7)
- # jobs-discuss (9)
- # juxt (9)
- # leiningen (14)
- # malli (3)
- # meander (6)
- # off-topic (77)
- # pathom (7)
- # re-frame (12)
- # reagent (8)
- # reitit (10)
- # restql (1)
- # shadow-cljs (22)
- # spacemacs (10)
but ran into issues doing that with Hiccup, since both macros were trying to compile the component’s children. so started directly using Helixs prop impl inside a parser instead (that’s why the demo does it like that too)
created an issue for this (https://github.com/alidlo/rewrap/issues/1) still have to figure out how to best mix the two since there’s some overlap
@lilactown here’s link to exact code: https://github.com/alidlo/rewrap/blob/master/rewrap/src/rewrap/interop.cljc#L42-L55
i kinda wish Helix separated it’s hooks/dev optimizations from its interop/compilation since the former can be used with any React wrapper, whereas latter is more opinionated
right now, for example, I’m writing a UI library. its written in Typescript, considering writing it in Clojurescript but then I’d have to choose a React wrapper making it less useful
I would take a PR for a helper macro like that specific to helix. Riffing on what you have there:
(defmacro generate-native-macros
[sym->impl]
`(do
~@(for [[sym impl] sym->impl]
`(defmacro ~sym [& args#]
(helix/$ (with-meta ~impl {:native true}) [email protected]#)))
is there anything specific about helix that is stopping you from using it to build a UI library?
opting for js just bc it by default has less code/opinions, not sure if there’s way around that
well, in my head, helix is so minimal and opinion-less that it’s just the same as writing in JS and using it with Fulcro or Reagent 😛
but I am probably biased, so I’m curious if there’s some specific choices that helix makes for you that make it feel like it impedes use w/ Fulcro/Reagent/Rum/etc.
I would also accept code size as a reasonable argument, I think that helix should be less code, for all that it does… not sure exactly how to accomplish that yet
code size and extensibility are my two arguments. e.g. above you baked in helix.core/$
as emitter macro when my whole goal was to make it custom 😜
it can be error prone to mix different react wrappers, e.g. mixing helix and hicada I ran into uses since they both compile props and children a certain way. so that’s why with rewrap wanted to make those things extensible
hmm. I guess my expectation is that you would expose them as react components, same as what you would get with writing them in TS
so e.g. if you had a component:
(defnc my-component
[{:keys [foo bar]}]
,,,)
then some reagent app would use it like:
(defn app []
[:> ui-lib/my-component
{:foo "foo" :bar "bar"}
,,,])
yea, i guess in that case it’d just a small code overhead, which I guess shouldn’t matter relative to entire cljs bundle we’re bringing in but psychologically it does 😅
FWIW at my previous job that’s exactly what we did: wrote our UI library components in JS/TS and then used them in our reagent app
i like it in general too, but in complex project TS error message become indecipherable
I know this is easier said than done, I'd really appreciate some docstrings on helix.hooks functions/macros. I could contribute some of them, but use-callback is eluding me.
I just didn't understand the arguments, I assumed it would be like use-effect
, it seems like it's more like react/useCallback
Use effect takes a body, but use-callback takes a fn-body, but in the arglist it's called a body too 🤕
useCallback(fn) in react is useMemo(() =>fn), so I always used useMemo because I find useCallback confusing
I have problems to understand react hooks too, and I only used use-state
and use-effect
until now 🙂
> I am fairly sure helix relies a bit on the react docs This is unrelated. I understand useCallback. I didn't understand what to pass to use-callback without reading the source. Same for use-effect, which implicitly adds a fn (unlike useEffect).
https://github.com/Lokeh/helix/blob/0.0.12/src/helix/hooks.cljc#L158 See implicit fn here, but not https://github.com/Lokeh/helix/blob/0.0.12/src/helix/hooks.cljc#L231
I haven't tried, can you tell me if the answer to "what to pass to use-callback" is the same as with plain react?
just make sure you use those hooks correctly, over-using them will cause performance issues.
It's not going to consume more memory than a single callback, and re-rendering twice is relatively expensive in comparison.
I never worried about re-render times, paint costs way more and that is optimized by default if I use identical props to components
that's what use-callback reduces too. I'm not certain, but the DOM will need updating if the callback function changes regularly.
honestly I regret the fancy thing I did with use-effect where it automatically wraps the body in a function
if that cb function itself never accepts arguments seems like a good choice to just accept its body is it just bc it differs from React?
yeah, it differs from react and prevents certain patterns like using higher-order functions
@lilactown Cool, if I get time this afternoon will spend some time on it
like legit tho I want to create a helix.hooks2
probably once I’m done with the defhook
machinery
my goal for defhook
is that you can add custom hooks that support for automatically filling in a deps vector and linting for unspecified deps
once that’s done I can create a new hooks namespace without all the macro code in helix.hooks
auto-filling the deps vector is <3, as long as you can turn it off (sometimes I want to ignore a value)
yep, it would work just like it does for use-effect
/ use-memo
/ etc. today, just for custom hooks
(use-custom-hook
:auto-deps ;; auto fill
#(foo bar))
(use-custom-hook
[foo] ;; ignore bar
#(foo bar))
Hi everybody. Just wanted to let you guys know that I created wrapper for emotion.js (styled component) https://github.com/khmelevskii/emotion-cljs It should be very useful to resolve problem working with css in cljs. This wrapper works good with helix.
yeah, and please let me know your feedback 🙂
nice @y.khmelevskii! this looks really similar to what we built at work but fuller featured 😄
yeah, we use it in our project and I decided that it’s not a lot of work to open source it. Happy to share it!
The other day I was so confident that it's easy to use render props, today I wasted more than 4 hours already on trying to use material autocomplete, and all I get is m.call is not a function. Not fun.
@y.khmelevskii how do you use with cljs?
if I have a lib like antd
, and it has its Button
how do you use with this?
(defstyled Button :button
{:display :flex
:color :red})
hey @fabrao. If antd/button
is react component you can do the following:
(defstyled Button antd/Button
{:display :flex
:color :red})
($ Button)
Oh, if I can only use Button instead of antd/Button I can call Button as MyButton
, right? Thank you
one thing I like about what we use at work is we add the namespace to the generated class name