helix

https://github.com/Lokeh/helix
Lucy Wang 2020-04-28T00:35:19.012600Z

@ashnur I think I gave you the wrong info. Passing a map/array is ok, not because of helix, but because react could either accept a singular children or iterables of children, viz., in react.createElement(type, props, child1, child2) child1 and child2 could be either a simple child, or an array, or a cljs vector/map (because all cljs collection types satisfies js Symbol.iterator)

Aron 2020-04-28T04:27:36.013700Z

@wxitb2017 no worries, the code example from the source helped a lot and I figured a way that works for me πŸ™‚

Aron 2020-04-28T04:28:13.014200Z

(apply react/createElement react/Fragment nil (mapv #($ CompName ...) (->clj files))

lilactown 2020-04-28T04:30:02.015400Z

you should be able to use (helix.core/fragment (map #($ CompName ,,,) (->clj files))

Aron 2020-04-30T00:45:44.036500Z

Is this something new, not released yet or the <> macro?

lilactown 2020-04-30T00:49:39.036700Z

ah sorry I meant <>

Aron 2020-04-30T00:51:02.036900Z

(<> (mapv (fn [[component, id, props]] (component (->js (merge props {:key id, :other "props for all"})))) [[GeneralInputComponent, "unique-id", {:specific "props"}]]))

Aron 2020-04-30T00:51:36.037100Z

this (or rather a much bigger version of it) results in hook errors and I can't understand why.

Aron 2020-04-30T00:52:18.037300Z

seems exactly like the kind of thing that would happen if I pass in duplicated keys for different components in the list though

Aron 2020-04-30T00:52:58.037500Z

or, if I am using some datastructure that doesn't keep order, but everything is in vectors

lilactown 2020-04-30T00:53:48.037700Z

you're calling component like a function

lilactown 2020-04-30T00:54:07.037900Z

you need to create an element out of it

Aron 2020-04-30T00:54:13.038100Z

I have to merge props deep

Aron 2020-04-30T00:54:22.038300Z

doesn't work with the $ macro

lilactown 2020-04-30T00:54:46.038500Z

($ component {& (merge props {:key id, :other "props for all"}))

lilactown 2020-04-30T00:55:21.038800Z

& does exactly the same as merge though

Aron 2020-04-30T00:55:26.039Z

"you need to create an element" that would require giving a name. Let me try this what you wrote last, I think I tried it before and something went wrong, but would be a good solution

lilactown 2020-04-30T00:55:56.039300Z

you always have to create components as elements, you cannot call them like functions. it will not work like you expect

lilactown 2020-04-30T00:56:02.039500Z

which is why you're getting hook errors

Aron 2020-04-30T00:56:29.039700Z

right, so I started using react/createElement

Aron 2020-04-30T00:56:45.039900Z

to which you answered and I didn't notice the $ in your example

Aron 2020-04-30T00:58:13.040100Z

works fine, thank you!

Aron 2020-04-30T00:59:00.040300Z

there are so many things to pay attention, it is quite easy to get in some bad loop of thinking trying everything but consistently missing something important

lilactown 2020-04-30T01:01:26.040800Z

that might help πŸ˜›

lilactown 2020-04-28T04:30:52.016200Z

using (apply react/createElement ,,,) is going to not force you to add keys to your components πŸ™‚

Aron 2020-04-28T04:43:50.016700Z

hmm, will try πŸ™‚

Lucy Wang 2020-04-28T05:59:24.017500Z

@lilactown I have ported the perf test to helix and intial results shows helix is 5x faster than reagent when creating 10k elements

Lucy Wang 2020-04-28T05:59:44.018Z

500ms v.s 2300ms

Lucy Wang 2020-04-28T06:03:12.018100Z

lilactown 2020-04-28T06:06:06.019Z

wow! thanks for doing that

Lucy Wang 2020-04-28T06:08:59.020100Z

The result for swapRows is wrong for helix ...

Lucy Wang 2020-04-28T06:09:10.020500Z

the prod build was overwritten by a dev build when I checkout branches

Aron 2020-04-28T06:10:07.021500Z

these things happen πŸ™‚ benchmarks are tedious, thanks for doing this work, I will definitely try it out too!

Aron 2020-04-28T06:10:17.021700Z

the difference looks quite significant

dominicm 2020-04-28T06:55:09.024400Z

That's great. https://github.com/roman01la/uix/blob/master/README.md#hiccup-interpretation claims to be 3x faster than reagent and 2x slower than react. Just for a relative comparison. It would be cool to compare uix on those performance measures too.

1
Lucy Wang 2020-04-28T09:42:56.025300Z

Sorry guys, there is a bug in my bench code, after fixing it the real results between helix/reagent is not that different ... https://github.com/krausest/js-framework-benchmark/pull/727/commits/ff352cec4fe3c702e7e123ef9a150a41735f0796

Lucy Wang 2020-04-28T09:43:45.025400Z

creating 10k elements, 3 rounds, react

Lucy Wang 2020-04-28T09:44:05.026600Z

the order of the screenshots are react-hooks, helix, reagent, react (contained in the image file name)

Lucy Wang 2020-04-28T09:45:18.027300Z

there is no significant differences among all of them.

Aron 2020-04-28T09:54:33.028700Z

It's good to know either way, and good to have the code too

lilactown 2020-04-28T17:33:01.030100Z

I find that surprising. I don’t see the vector allocations in those graphs for reagent