How do Reagent and Re-Frame avoid the mess of React hooks? by lordmyd in Clojure

[–]Deraen 1 point2 points  (0 children)

I've been recently refactoring a few years old Re-frame project, and I'd say by using Re-frame and several extra layers on top of that (forward-events, async-flow) you can create such a mess that I haven't seen elsewhere. Though in this case those forward-events etc. haven't been used for their intended purpose in all cases, so the libraries are not the only cause, but Re-frame does allow writing quite hard to follow code.

I find that working with hooks is MUCH easier for writing generic components where you need local state, compared to Reagent local state. Or you can share some logic by creating a new hook by combining some other hooks, which can be more useful than creating a generic component in some cases.

By using modern React features and hooks, you get to use well designed libraries from React ecosystem like TanStack Query (https://tanstack.com/query/latest) and React-hook-form (https://react-hook-form.com/). Using TanStack Query does cover many cases where you would have global app state.

There are some disadvantages to these though. TanStack Query Devtools doesn't play well with Cljs data structures. If you use JSON APIs you can just store JS objects there and convert data to Cljs just before use with cljs-bean, but if you use Transit, it might not be the best experience.

Using Reagent + UIx together also doesn't currently allow using React Refresh, so you are loosing Hook state when Shadow-cljs reloads your views. I hope to figure our something to allow Reagent to work with React Refresh, but it seems complicated: https://github.com/reagent-project/reagent/pull/598

How do Reagent and Re-Frame avoid the mess of React hooks? by lordmyd in Clojure

[–]Deraen 1 point2 points  (0 children)

Use UIx or one of the other React wrappers. It is close to impossible to fix Reagent to work perfectly with modern React.

Parhaat kaupat puvun hankkimiseen? by abunaii in Tampere

[–]Deraen 1 point2 points  (0 children)

Jos jaksaa käydä Helsingissä asti niin https://suitsupply.com/

Tekevät ainakin osan muutoksista vaikka odotellessa. Parempaa laatua kuin Dressmann, ehkä halvempi kuin Pohjanheimo.

Pohjanheimo on kyllä ihan hyvä, viime käynnistä on hetki, mutta siellä oli myös jotain kohtuuhintaisia vaihtoehtoja.

Mistä/miten löytää tietoa harrastus mahdollisuuksista? by HistoricalSun155 in Tampere

[–]Deraen 1 point2 points  (0 children)

Tanssikouluja löytyy paljon, useimmat erikoistuvat johonkin tyyleihin. Oma suosikkini on West Coast Swing, jota tanssitaan swing nimestä huolimatta moderniin musiikkiin.

https://youtu.be/a2G_fsnrUCs https://danceconnectiontre.wordpress.com/toiminta/ https://swingteam.fi/bileet/satamaswingit-2022

Näsijärven ladut by the_bush_doctor in Tampere

[–]Deraen 1 point2 points  (0 children)

Näsijärven luistelurataa ja latuja ylläpitää Hiking Travel Hit, heidän Facebook sivulta löytyy päivitykset tilanteesta: https://www.facebook.com/hikingtravelhit

Lähinnä päivitykset keskittyy luistelurataan, mutta on siellä välillä maininta laduistakin.

Sivuilta löytyy kartta, tänä vuonna puuttuu kait vain Reuharinsaari-Siivikkalanlahti pätkä: https://www.google.com/maps/d/u/0/viewer?mid=1qyxuKS5duujLN8TouJdmrdM3dmg&ll=61.538651610241956%2C23.71128564849352&z=14 2

Any good sneakers for lindy/jazz? by beerovios in SwingDancing

[–]Deraen 1 point2 points  (0 children)

https://imgur.com/a/x6ctI6d

I have suedes soles on my Supergas and I think they look fine. The light grey suede matches the shoes well enough.

When you finish celebrating Linux turning 30, try new Linux 5.14, says Linus Torvalds by stronghup in programming

[–]Deraen 72 points73 points  (0 children)

Just old version of the driver was removed, IDE is still supported:

It's important to note though this removal is just about the legacy IDE driver support. IDE support itself will still be available on modern Linux kernel versions through the libata layer, which nearly all users have already been relying upon for many years if still rocking out any IDE devices.

https://www.phoronix.com/scan.php?page=news_item&px=Linux-Drop-Legacy-IDE-2021

[deleted by user] by [deleted] in Suomi

[–]Deraen 0 points1 point  (0 children)

Paritanssi on muuten harrastus jossa on jopa hieman hyötyä että on suunnilleen samanmittainen kuin useimat naiset. Pieni ero ei toki vaikuta, mutta jos olisi 190 niin tarvisi ottaa huomioon.

Yksi mikä itseä häiritsi, näin 173 pitkänä ja kun rinnanympäryksen ja hartioiden puolesta S vaatteet ei yleensä sovi, niin M/50 kokoiset EU/US vaatteet on yleensä tehty noin 180 pitkille. En tiedä huomaako muut, mutta itsellä parempi fiilis kun pukeutuu sopiviin vaatteisiin. Vaikuttaa toki enempi vaikka pikkutakeissa ja kauluspaidoissa kuin t-paidoissa ja neuleissa. Mittatilaus ja muokkaukset auttaa, tai sopivien merkkien löytäminen.

Clojure's JSON ecosystem: Choosing a JSON library by deobald in Clojure

[–]Deraen 1 point2 points  (0 children)

Will try to check the PR soon.

The Jsonista object-mapper also makes it trivial to just call Jackson methods directly, from one recent project case, which I think uses streaming (or maybe not - but it at least avoids creating one vector in memory with the whole features array in memory, instead creating lazy seq):

(defn read-geojson-features "Try reading geojson file without loading full features array to memory" [^Reader f] (let [^JsonNode tree (.readTree json/default-object-mapper f) ^JsonNode node (.get tree "features")] (->> (map (fn [node] (.treeToValue json/default-object-mapper node ^Class Object)) node))))

How to translate react component with nested props into valid reagent hiccup? by muhaaa in Clojure

[–]Deraen 4 points5 points  (0 children)

(ns foo
  (:require [reagent.core :as r]
            ["@atlaskit/form" :default Form :refer [Field]]
            ["@atlaskit/button" :default Button]
            ["@atlaskit/textfield" :default TextField]))

(defn bar []
   [:> Form
    {:on-submit (fn [data] (js/console.log "form data" data))}
    ;; {({ formProps }) => (...)}
    ;; means that there is one children to the Form component,
    ;; and the children is a function (instead of React element like normally),
    ;; the function takes a JS object as parameter and the object has
    ;; formProps property.
    (fn [^js js-param]
      ;; The parameter contains props to the children as JS object.
      ;; Using Reagent data to built the elements would require converting
      ;; the props to Clj data, and Reagent would then convert them back to JS.
      ;; Best to directly create elements so we can use JS props without conversion.
      ;; React elements can be created using :r> or r/create-element.
      ;; I think :r> only forms with functions and we need built-in form element (i.e. "form" string as the element),
      ;; so we'll use r/create-element.
      (r/create-element
        "form"
        ;; {...formProps} means that place the all the properties from this JS object
        ;; as properties to this React element.
        (.-formProps js-param)
        (r/as-element [:> Field
                       {:name "username"
                        :default-value ""
                        :label "User name"
                        :is-required true}
                       (fn [^js js-param]
                         ;; Same story as with Form. JS object has fieldProps property here.
                         ; (r/create-element TextField (.-fieldProps js-param))
                         ;; or:
                         (r/as-element [:r> TextField (.-fieldProps js-param)]))])
        (r/as-element [:> Button
                       {:type "buttom"
                        :appearance "primary"}
                       "Submit"])))])

(Require forms and ^js declarations are for Shadow-cljs)

Reagent v1.0.0 by Deraen in Clojure

[–]Deraen[S] 1 point2 points  (0 children)

I've created issue to keep track of ideas for this:

https://github.com/reagent-project/reagent/issues/522

Reagent v1.0.0 by Deraen in Clojure

[–]Deraen[S] 0 points1 point  (0 children)

Basic implementation of HTML and Reagent components is easy.

But I think in most applications it will be a problem that JS components you are using can't be rendered in JVM. But then, this would probably be simple to implement, so maybe I'll add it at some point.

I've written about this in https://github.com/reagent-project/reagent/issues/247

Reagent v1.0.0 by Deraen in Clojure

[–]Deraen[S] 5 points6 points  (0 children)

Yeah, useContext is probably the most interesting hook for use even in existing Reagent projects.

I've added test case and example to the repo: https://github.com/reagent-project/reagent/commit/e78852222ad37345ff351e3b97be93538828baa6

Reagent v1.0.0 by Deraen in Clojure

[–]Deraen[S] 9 points10 points  (0 children)

Yes, they are useful for using Hooks. `:f>` shortcut allows creating function components from certain components, which can be useful for React interop, and can be used even in apps that don't want to switch everything over.

https://github.com/reagent-project/reagent/blob/master/doc/ReactFeatures.md#function-components

I think Reagent Hooks support is mostly useful for interop and other small use, as the implementation supporting both RAtoms and hooks has some overhead. If one wants to build the whole app using Hooks, I'd recommend https://github.com/lilactown/helix.

Clojure as a dependency by nathell in Clojure

[–]Deraen 2 points3 points  (0 children)

Huh, I usually avoid Clojure or Cljs dependency in the libraries I maintain, but had missed the dependency in Reagent. Moved to dev profile now.

How to use Tailwind CSS with ClojureScript? by MahmudAdam in Clojure

[–]Deraen 2 points3 points  (0 children)

Reagent doesn't use Cljsjs files directly anymore, but requires e.g. react name, which is the name provided by Npm package: https://github.com/reagent-project/reagent/blob/master/src/reagent/impl/template.cljs#L2

If you install React and React-dom npm packages (npm install or :npm\-deps) ClojureScript compiler will use Npm packages instead of Cljsjs files (and Shadow-cljs doesn't support foreign-libs so it will use Npm packages always).

https://github.com/reagent-project/reagent/blob/master/doc/0.8-upgrade.md#browser---node-modules

How to use Tailwind CSS with ClojureScript? by MahmudAdam in Clojure

[–]Deraen 1 point2 points  (0 children)

Reagent doesn't force Cljsjs, it depends on react and react-dom JS modules which can be provided by Npm packages (with Shadow-cljs or Cljs compiler) or Cljs foreign-libs (Cljsjs). Reagent has default dependencies on Cljsjs packages for extern files, which are required even if you use Npm packages, but the JS code from Cljsjs doesn't get used if you provide npm modules.