demo: https://twitter.com/borkdude/status/1557380028450619393
This feels darned close to writing direct React in JS :)
is that a good thing? 🫣
use the REPL, dude. 😜
Well, there are these alternative libraries to Reagent that try to be closer to directly using React. I don't think you can get any closer to react than this ;)
Yeah the main function a react wrapper does is provide an easy way to write elements and destructure props. With a few syntax adjustments to the core language, it's simple 😎
Didn't mean to offend anyone ;)
Now I pissed off the REPL people AND the React-wrapper people! <throws computer in lake and archives project/>
On a more serious note, @lilactown what do you think are the other "core" features of a React-wrapper?
that's basically it IMO
i wrote my rationale for "why helix" here https://github.com/lilactown/helix/blob/master/docs/motivation.md which lays out my thoughts with a bit more detail
helix adds some more stuff on top by leveraging macros to do static analysis, e.g. providing point-of-use detection of invalid use of hooks, and generating signatures for hot reloading components that maintains local state
but that's more icing, and could be adopted a la carte rather than as an all-in-one "react wrapper"
i'd happily delete helix if clojurescript core removed the need for it 😄
Is this something that could actually happen, you think? Or is it just a result of how clojurescript fundamentally is built?
For me, it needs to provide better tools for working with JS objects. ideally treating POJOs as maps. I don't think that's reasonable for CLJS to do, but i could be wrong
@lilactown If those are the core ingredients of a react wrapper: just a macro for generating React elements + something like js-interop which supports destructuring js objects is sufficient I guess
The difference with the cherry propotype above is that it directly generates jsx (so no createElement) and that cherry natively supports destructuring on js objects. I think the latter could be built into CLJS, I don't see why not
right yeah
In fact, I think the only change that would be necessary in CLJS support for js objects on the get function
I'll bounce this idea in #cljs-dev
i think it gets tricky with advanced compilation
hm right
@borkdude Destructing on JS objects is supported, if you extend some protocols to the object type, see: https://stackoverflow.com/questions/49726019/can-you-destructure-a-javascript-object-in-clojurescript
I saw your comment: indeed, why isn't this supported out of the box
Supporting it as a special case in get rather than doing it via the protocol would likely make it faster too
hey @mfikes, any insight on why this isn't supported?
Checked in the code and published a new alpha version in case anyone wants to have a play with this. https://github.com/borkdude/cherry/blob/main/examples/jsx/pages/component.cljs
I actually wrote the above stuff with bun create next jsx and bun dev
I figured that since bun is all the hype right now, maybe cherry could be the clojure sidekick of bun 🍞
Hi @borkdude - I just found a bug - (- 20) returns 20 instead of -20
preemptively: https://clojurians.slack.com/archives/C03QZH5PG6M/p1659856344637859?thread_ts=1659855908.267939&cid=C03QZH5PG6M
Thanks for finding this! Posting an issue is indeed the way to go
I fixed it now already in alpha 51
Also, I'm really loving this project so far - support for JSX in ClojureScript can be a killer feature!
4
oh, whoops, this isn't a terminal