A minimalistic ClojureScript interface to React.js
NoahTheDuke 2021-04-19T13:45:26.137600Z

i've never heard of emotion, this is cool as heck

lilactown 2021-04-19T15:34:44.138400Z

@nbtheduke your post here is correct:

lilactown 2021-04-19T15:37:09.138700Z

I don't know what your question is, though

lilactown 2021-04-19T15:37:15.138900Z

why what happens?

NoahTheDuke 2021-04-19T16:01:16.141500Z

Why does creating a cursor inside of the function provide such a speed up? If passing game in is the issue (because every time it changes everything as to rerender), why doesn’t the rerendering slowdown happen inside of this function too?

NoahTheDuke 2021-04-19T16:01:41.142400Z

I would expect that creating the cursor at the top level is the only way to avoid rerendering but that’s not the case

athomasoriginal 2021-04-19T17:09:34.145600Z

I believe what is being highlighted is that if your component(s) are listening for a change to any key in the atom this will trigger re-renders at a higher frequency because your component might only care about :a , but :b was updated and now the whole component re-renders However, if you use a cursor your components will only re-render when the specific key in the cursor has changed. The result is that you get less re-renders because you’re only listening for changes to specific keys in the atom, not any key.

athomasoriginal 2021-04-19T17:11:04.146600Z

Having said this, if you have 1 flat component and use a cursor this by itself doesn’t make the rendering more performant.

athomasoriginal 2021-04-19T17:12:37.147700Z

You would have to strategically use cursors in some components and not others and possibly at different levels of nesting.

NoahTheDuke 2021-04-19T17:21:05.148700Z

interesting, thank you

lilactown 2021-04-19T20:47:13.149Z

I'm not convinced that the examples in that article are correct

NoahTheDuke 2021-04-19T20:48:33.150400Z

i ran the code with updated deps, and it's certainly faster, but not by much

lilactown 2021-04-19T20:48:47.150600Z

you're right to be suspicious of that snippet you pasted.

lilactown 2021-04-19T20:49:41.151700Z

the issue isn't reconstructing the cursor every time, but the fact that you don't save anything by using cursors in this case because every time the game cursor re-renders, the player-component will re-render regardless

lilactown 2021-04-19T20:49:56.152Z

which is ostensibly what the player cursor is trying to avoid

lilactown 2021-04-19T20:50:49.152700Z

the reason they saw any perf benefits at all was due to the game cursor removing the dependency on the full games ratom

lilactown 2021-04-19T20:51:05.153100Z

so you can update game 1 and it won't re-render the component depending on game 38

lilactown 2021-04-19T20:51:15.153400Z

but if you change any player in game 38, it will re-render the entire list of players