This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-10
Channels
- # adventofcode (76)
- # announcements (7)
- # aws (3)
- # babashka (75)
- # beginners (25)
- # calva (37)
- # cider (9)
- # clara (4)
- # clj-kondo (17)
- # cljsrn (1)
- # clojure (106)
- # clojure-europe (4)
- # clojure-india (2)
- # clojure-italy (12)
- # clojure-nl (27)
- # clojure-spec (33)
- # clojure-uk (20)
- # clojurescript (103)
- # clojutre (3)
- # core-async (1)
- # cryogen (10)
- # cursive (24)
- # datomic (113)
- # dirac (5)
- # emacs (12)
- # events (4)
- # fulcro (64)
- # garden (5)
- # jobs (1)
- # kaocha (5)
- # luminus (2)
- # malli (14)
- # off-topic (53)
- # planck (11)
- # re-frame (9)
- # reagent (16)
- # reitit (26)
- # remote-jobs (2)
- # shadow-cljs (137)
- # spacemacs (34)
Last time there was a longer discussion about it, using Core async with this helper was the outcome
Is it possible/feasible to migrate an existing React app to Clojurescript component-by-component? Rewriting the whole app isn’t feasible for this project but is it possible to do it piece-by-piece?
Probably possible, but I don’t know about feasible. The caveat is that once you include ClojureScript, you get the overhead of Clojure/Closure in there (much of it is the immutable data structures). This will come out pretty much as +/-0 vs a JS app for non-trivial examples, since it usually takes care of a bunch of stuff you’d use third-party libs for in JS. But while both are in there, you’ll have overhead.
I believe clojurescript adds ~400kb gzipped, but I might be mistaken?
Supposing I’m fine with the overhead, how can this migration work? Can clojurescript use React components written in JS(X)? Or, can JS(X) React components use components transpiled from clojurescript? Which embeds which? How do I start? 🙂
The various React wrappers typically have helper functions for you to import React classes. #reagent has adapt-react-class
, for example: <https://github.com/reagent-project/reagent/blob/bd8603dce8e675fd4fe4f8c841c4369e4e39421d/src/reagent/core.cljs#L53>
#fulcro has react-factory
and react-input-factory
: https://github.com/fulcrologic/fulcro/blob/d67c07b4b55be1119522c1954b33bc819c8c9f67/src/main/com/fulcrologic/fulcro/algorithms/react_interop.cljc#L7I
I think you’ll generally have a better time importing your existing codebase into CLJS than the other way around.
A starting point might be to just pick #reagent for now (since it’s quick to get started, even though #fulcro and #re-frame provides a lot of additional value for those fully in the CLJS ecosystem), look into how you can expose your existing components as a big fat lib, get yourself #shadow-cljs set up, import the lib, and mount it with #reagent, and see if it renders as expected. Then you can get started rewriting the components from the root up.
Does anyone know best practice css with clojurescript / reagent / reframe? If I want to avoid producing unmaintainable css in the future, what would be a good clojurish approach?
It just occurred to me recently that clojurish applications might be better served by more niche css systems.. And not your usual boktstram material ui, semantic ui etc.
I used some CSS-in-CLJS for a while but really wouldn't recommend it anymore https://github.com/thheller/shadow/wiki/shadow.markup
it might be for you ... it is no longer for me. too easy to be inconsistent ... too hard to name every single element
dunno that was the part I like the most .. no need to worry about selectors conflicting with each other or cascade messing with your elements
:div.flex-1.bg-white.text-gray-800.font-bold.border-r.border-gray-300.rounded-tl-sm.cursor-pointer.px-2.py-2
@thheller do you have any good reference project to get started with tailwindcss togher with shadow-cljs? I had a look at https://github.com/yannvanhalewyn/boyscout and read the official tailwind-docs (used shadow-cljs before) 🙂 .
I see. Thanks!
Comment from another thread in here:
> Be careful with any pprint
s left in, that can add an unexpected chunk
I've seen this in my bundles as well. Anyone know a lightweight alternative for rendering data structures in a dev-friendly way that doesn't add as much to the bundle size?
@dpassen1 I'm not sure what tap>
refers to, sorry. Also, the only remaining pprint is for devtools we have use for in production as well
I have a long-ass list and everybody have wide-screens, how can I have 2 divs in parallel and 1 scrollbar and 2nd divs first item is always the item after the first divs last item. Does that makes sense? Do I need to calculate is this item showing up in the first div for every item I have to make this work?
@henrik lets say I have a list [l1 l2 l3 l4 l5 l6]
what I want to have is
l1 l3 | l2 l4 |
l2 l4 | --after scroll--> l3 l5 |
@U2FRKM4TW I cant see how flex-wrap
could me for this :G
Oh, after the example I see what you mean. I have no idea if that can be implemented in plain CSS. And to be honest, I really doubt that that would be a good UX.
Anyone have a good way to diagnosis why a react suspense function would only ever return the fallback component and never the main one? I see no console errors.
Is that question for me 🙂
Ah, I understand the question. If the promise never resolved it will be suspended forever.
hi everyone, i have a list of IDs in a [:select]
I am populating them from the app-db through a sub via for loop
[:div
[:select {:multiple "multiple"
}
(for [id ids]
[:option {:key id}
(str id)])]]
I am trying to implement a search bar that would filter matching ID numbers. It would look something like this. can not figure out the ID search functionality. I tried :on-change #(reset! ids (-> % .-target .-value))
but not luck. using re-frame.
Whenever user types something to input box, filter the ids
in the re-frame db
based on the input, assuming ids
coming from a re-frame subs
this should work. (Better debounce the filtering instead of filtering on every character typed.)
thanks i will look into it 🙂
I was thinking of doing something like a set/intersection, but this might be a good one too
@UFHB0T69M hmmm, so are you suggesting creating a filter component? that's a pretty cool idea!
yep, good suggestion! works well. thanks again! 🙂
What's the best way to set global css for the html
and body
tags when you're using reagent?
I’d probably import something like this and use it: https://github.com/nfl/react-helmet