cherry

borkdude 2022-08-10T08:51:43.950949Z

jsx idea: https://github.com/borkdude/cherry/issues/49

borkdude 2022-08-10T09:58:43.058109Z

demo: https://twitter.com/borkdude/status/1557380028450619393

borkdude 2022-08-10T15:10:04.453409Z

This feels darned close to writing direct React in JS :)

mkvlr 2022-08-10T15:12:01.477869Z

is that a good thing? 🫣

😝 1
mkvlr 2022-08-10T15:13:36.671119Z

use the REPL, dude. 😜

borkdude 2022-08-10T15:18:57.267159Z

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 ;)

👍 1
lilactown 2022-08-10T15:39:30.481909Z

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 😎

borkdude 2022-08-10T15:39:52.306609Z

Didn't mean to offend anyone ;)

borkdude 2022-08-10T15:40:09.220189Z

Now I pissed off the REPL people AND the React-wrapper people! <throws computer in lake and archives project/>

😂 11
borkdude 2022-08-10T15:57:46.459519Z

On a more serious note, @lilactown what do you think are the other "core" features of a React-wrapper?

lilactown 2022-08-10T17:41:35.267749Z

that's basically it IMO

lilactown 2022-08-10T17:42:48.968149Z

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

lilactown 2022-08-10T17:45:18.161859Z

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

lilactown 2022-08-10T17:46:12.278509Z

but that's more icing, and could be adopted a la carte rather than as an all-in-one "react wrapper"

lilactown 2022-08-10T17:47:07.120639Z

i'd happily delete helix if clojurescript core removed the need for it 😄

😂 3
2022-08-10T17:49:28.463089Z

Is this something that could actually happen, you think? Or is it just a result of how clojurescript fundamentally is built?

lilactown 2022-08-10T17:52:00.064479Z

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

👍 1
borkdude 2022-08-10T17:53:10.160449Z

@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

borkdude 2022-08-10T17:54:05.666859Z

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

lilactown 2022-08-10T18:04:06.077689Z

right yeah

borkdude 2022-08-10T18:04:51.720279Z

In fact, I think the only change that would be necessary in CLJS support for js objects on the get function

borkdude 2022-08-10T18:05:35.377739Z

I'll bounce this idea in #cljs-dev

lilactown 2022-08-10T18:06:21.035839Z

i think it gets tricky with advanced compilation

borkdude 2022-08-10T18:07:03.417739Z

hm right

2022-08-12T07:08:49.346379Z

@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

borkdude 2022-08-12T07:16:32.286169Z

I saw your comment: indeed, why isn't this supported out of the box

🤷 1
borkdude 2022-08-12T07:17:02.954319Z

Supporting it as a special case in get rather than doing it via the protocol would likely make it faster too

2022-08-12T14:25:33.738029Z

hey @mfikes, any insight on why this isn't supported?

borkdude 2022-08-10T19:52:32.320859Z

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

borkdude 2022-08-10T19:55:04.518559Z

I actually wrote the above stuff with bun create next jsx and bun dev

borkdude 2022-08-10T19:59:28.809619Z

I figured that since bun is all the hype right now, maybe cherry could be the clojure sidekick of bun 🍞

🍞 5
mauricio.szabo 2022-08-10T23:10:08.102699Z

Hi @borkdude - I just found a bug - (- 20) returns 20 instead of -20

borkdude 2022-08-11T09:45:29.249649Z

Thanks for finding this! Posting an issue is indeed the way to go

borkdude 2022-08-11T10:04:46.538739Z

I fixed it now already in alpha 51

mauricio.szabo 2022-08-10T23:33:22.847029Z

Also, I'm really loving this project so far - support for JSX in ClojureScript can be a killer feature!

❤️ 1
Cora (she/her) 2022-08-10T23:52:31.399949Z

4

4️⃣ 5
Cora (she/her) 2022-08-10T23:52:39.733079Z

oh, whoops, this isn't a terminal

😆 1