Earlier quoted context omitted.
Add me to this club of JSX hackers: https://crwi.uk/posts/hiccup/ I used this approach to make a syntax highlighted text editor in https://crwi.uk/experiments/text-editor/
These are awesome (both parent comments). Love seeing that I'm not alone in my JSX curiosity.
Show HN: A JavaScript UI library for imperative JSX
41–50 of 55 posts
Re: Show HN: A JavaScript UI library for imperative JSX
#42Earlier quoted context omitted.
Same, used jQuery for years and had a love/hate relationship with it. You're correct that React solved the imperative problems from before, but that's not the only factor to consider. You have to weigh the problems it solves against the problems that it causes.
Eh. For me, it was vastly worth it. Yes there are drawbacks to react. But I feel like the gains far far far outweigh them.
Re: Show HN: A JavaScript UI library for imperative JSX
#43setContent(css`p[key=counter]{ content: 'The count is ${count}'}; }`);
Re: Show HN: A JavaScript UI library for imperative JSX
#44Re: Show HN: A JavaScript UI library for imperative JSX
#45I would never want to write it the same element in multiple places like this. That's one of the main points of templating in the first place: to write the code for a piece of output once, with all of the bindings that can affect it. What happens here if you update the JSX for an element in one place and forget to do so in the others?
Re: Show HN: A JavaScript UI library for imperative JSX
#46Why not use template literals and a css like syntax for selecting and update? setContent(css`p[key=counter]{ content: 'The count is ${count}'}; }`);
Re: Show HN: A JavaScript UI library for imperative JSX
#47Earlier quoted context omitted.
Agreed! About 5 or 6 years ago I wrote a library to demonstrate to my teams that JSX a) was not magic b) not limited to React. After that was done I became a little obsessed with making the library the fastest JSX renderer - which I think is still true: https://github.com/i-like-robots/hyperons
Add me to this club of JSX hackers: https://crwi.uk/posts/hiccup/ I used this approach to make a syntax highlighted text editor in https://crwi.uk/experiments/text-editor/
Re: Show HN: A JavaScript UI library for imperative JSX
#48Earlier quoted context omitted.
Sure! There are several, but let's take a trivial one - setTimeout. This is an example of something that is inherently imperative, and therefore requires some awkward logic to get it working correctly in React. Here's an article explaining how to do it: https://codedamn.com/news/reactjs/how-to-use-settimeout-in-r... In contrast, here's how you would do it in matry: let someValue = 0; setTimeout(() => { someValue++; s…
This is IMO a great example for React and declarative programming. > There's no special concept to understand By not understanding that you need to cleanup timers when your view unmounts, you've introduced a subtle bug that your coworker will discover in 6 months when users report that the counter sometimes increases twice as fast. I've worked on Angular-like apps before, and storing and cleaning up timers was always…
interval(1000).pipe(…)…
Puts the timer up front and center. There's some confusion between "hot" and "cold" to deal and sharing with, but the pipelines eventually clean themselves up and the higher-level operators can be very nice to you if you let them.Re: Show HN: A JavaScript UI library for imperative JSX
#49Earlier quoted context omitted.
Add me to this club of JSX hackers: https://crwi.uk/posts/hiccup/ I used this approach to make a syntax highlighted text editor in https://crwi.uk/experiments/text-editor/
Very cool - reminded me of https://github.com/creationix/dombuilder which I have... memories of. Shout out too to https://microjs.com/ for allowing me to relive some nostalgia.