reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
jeaye 2021-03-12T17:06:29.023Z

I've used reagent a ton, but never any vanilla JS + React. I'm curious, does vanilla JS + React allow components to be so easily made from pure data transformations? Simple example being code like (into [table] (map (fn [r] [row r]) @rows) , but this also carries over to transforming existing hiccup forms by way of conj or similar.

jeaye 2021-03-13T19:52:18.025200Z

Yep, I focused on all of the data we needed to transform in order to build the UIs, along with how the shape of that data is highly ambiguous. Ended up with an approval.

p-himik 2021-03-13T19:56:03.025400Z

Awesome!

p-himik 2021-03-12T17:15:11.023100Z

<table> in JSX will result in a call to React.createElement(...). A resulting React element is an immutable data structure. All you can do to it afterwards is to call React.cloneElement(...) and override some properties and children. So, you cannot simply (conj [table ...] new-child), but you should be able to achieve the same result.

jeaye 2021-03-12T17:16:27.023300Z

Right, anything you can do in reagent, you can do with React in JS. What you're alluding to is exactly my core inquiry, though: how painful is it?

p-himik 2021-03-12T17:18:28.023500Z

No idea, I've actually never used JSX myself. :)

jeaye 2021-03-12T17:35:35.023700Z

I'm trying to make the case to some folks for using CLJS + Reagent over JS + React, which is why I ask.

p-himik 2021-03-12T17:37:56.023900Z

If those folks never use cloneElement, then it would be harder to make such a case.

p-himik 2021-03-12T17:39:19.024100Z

FWIW, I think it would be much easier and also more productive to make a case of CLJS vs JS, and then show that Reagent experience is also at the very least comparable to React.

lilactown 2021-03-12T21:32:48.024300Z

IME working on large applications, manipulating children as data is a code smell to me. it usually couples the parent and children in ways that make it very difficult to untangle

lilactown 2021-03-12T21:35:36.024500Z

if I was selling CLJS + Reagent, I would focus on the ease of using immutable data and the rich standard library via clojure.core, and the reactive MobX-like paradigm that reagent's ratom/reactions provide