This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-30
Channels
- # announcements (15)
- # beginners (143)
- # boot (2)
- # calva (48)
- # cider (93)
- # cljsrn (2)
- # clojure (127)
- # clojure-europe (3)
- # clojure-italy (8)
- # clojure-losangeles (8)
- # clojure-nl (10)
- # clojure-spec (67)
- # clojure-uk (51)
- # clojurescript (20)
- # cursive (9)
- # data-science (2)
- # datomic (10)
- # duct (13)
- # figwheel-main (1)
- # fulcro (74)
- # instaparse (10)
- # jobs (3)
- # joker (8)
- # juxt (4)
- # lumo (1)
- # malli (11)
- # nrepl (3)
- # off-topic (4)
- # pathom (5)
- # pedestal (6)
- # planck (5)
- # re-frame (18)
- # reagent (5)
- # reitit (17)
- # shadow-cljs (165)
- # sql (30)
- # vim (12)
- # xtdb (6)
if one was to explore frontend development using Clojure, what's the trend? Reagent?
this "friend" is a backend developer who is very put off by frontend shenanighans, but willing to try something "new" provided it doesn't mean spinning up a bazillion different stacks just to do something nice š
reagent/re-frame is a safe choice for a clojure dev. Iād recommend shadow-cljs for doing the cljs building, eliminates a bunch of pain points and shouldnāt mean spinning up a bazillion different stacks
personally imo the exciting edge is React itself - concurrent mode, suspense, hooks etc. If you want to use that, then the library hx makes it easier to interop
yep - this one https://github.com/Lokeh/hx
it does a lot less than reagent et al, with the intention that you interop more directly with react
has your āfriendā got a project in mind
I spent some time looking into react/cljs frameworksā¦ and developed workarounds to write isomorphic clojure(script) with SSR. My current feeling is that reagent (and consequently reframe) will eventually be obsoleted by smaller libraries, one of which might be just react itself. The biggest work (Iād like to see done here) is to have an isomorphic hiccup dialect, that supports something like reagent flavoured hiccup. There are lots of hiccup dialects, but none that I have found that are properly isomorphic to clojure rendered HTML and CLJS backed react components. I think fulcro might do this, but fulcro incorporates too much of a framework mindset for my liking. My main problem with reframe is that itās only for SPAs and doesnāt work very well for isomorphic apps with SSR. Weāre currently building an isomorphic clojure(script) app which does SSR ā but to do so we had to implement a bodge to do it. Essentially we use reagent (not reframe), and wrote a simple reagent-flavoured hiccup interpreter that can isomorphically run reagent cljc components on the server on the JVM. A simpler solution in my mind would be to ditch reagentās state management, shim react hooks on the server (super trivial), and use an isomorphic libā¦ then incorporate whatever pattern/system you want for state/flow etc; if you need it.
Incidentally @dominicmās post is probably the best post that sums up 1/2 of this desire: https://juxt.pro/blog/posts/react-hooks-raw.html
If you donāt need SSR, you can probably just use reframe. We do a lot of work government and therefore have accessibility requirements. And the best way to meet 90% of accessibility requirements is to ship stuff that works without javascript and can work as such from an initial SSR; as itās much simpler to verify behaviour without having to do full-blown accessibility testing which is very expensive; and even more so if you depend on RIA stuff to make javascript accessible. I suspect weāre probably some of the only people who still make sites that arenāt completely broken without javascript, and that progressively enhance from that point.
Re-frame doesn't exclude SSR though; we render large parts of our frontend app on the server š
Sure. It depends if you can split it. It does exclude isomorphic SSR for the reactified SPAs DOM tree.
Of course. We're actually researching ways to "switcheroo" between SSR and React - partly for novelty, partly because it'd be useful
Yeahā¦ my conclusion was that reframe has too large a surface to shim and events etc donāt exist on the server. But you can more easily hack it by dropping the re-frame bells and whistles, and shimming a delay serverside over a reagent atom, and tree-walking the reagent-flavour hiccup server side like itās a mini lisp machine. Thatās essentially what we do. It works quite well, so long as you keep the client side interactions relatively simpleā¦ i.e. simple enough not to require something like re-frame.
It sounds like our solutions are similar, although we opted to shim re-frame and it is mostly just to avoid reader macros all over the place!
yeah ā I wanted to avoid a rats nest of reader macrosā¦ you can obviously shim with them ā but itās too granular. And I wanted to avoid shiming re-frame, as thereās quite a lot of it.
I also didnāt want to change the programming model on the server. The server side should just be ask the DB for some data, coerce it into a value/datastructure of your choice, and apply that to your view template function.
@rickmoynihan is the writeup āWhat react hooks mean for clojurescriptā a good place to lookover what youāve described? Or just part of it?
Yeah itās more an interesting side note about what I think should be the direction for front end. I wanted to do that stuff, but found I couldnāt because there isnāt an isomorphic implementation of reagent-flavoured hiccup. Though note my requirements are to have an isomorphic app with SSR. If you can do an SPA with only a holding DOM to bootstrap from clientside, then that article is probably all you need, along with (optionally) a clojurescript hiccup implementation.
ServerSide Rendering then
Ok, anywhere thatās got a more complete writeup? Or should I just be paying more attention to the chat ;)ā¦
Thereās no more complete write up that Iām aware ofā¦ except possibly in a few comments on our issue tracker somewhere. Itās mainly something I wish existed. I donāt think Iām the right person to solve it though. I have a work around, that seems good enough for now.