r/reactjs • u/isumix_ • Nov 18 '23
Discussion How I wanted to improve React
https://medium.com/weekly-webtips/how-i-wanted-to-improve-react-4108d5052aaf[removed] — view removed post
1
Upvotes
r/reactjs • u/isumix_ • Nov 18 '23
[removed] — view removed post
2
u/fii0 Nov 18 '23
My goodness gracious, have you heard of Svelte? It addresses all of the same problems, without the drawback of needing to explicitly call a
component.update()function. You can claim that it's "less flexible" and avoids "mixing of responsibilities". Not even disagreeing with the idea that it's mixing responsibilities, but if I am doing rendering logic outside of a <canvas> and usingwindow.requestAnimationFrame(), I do not want to be responsible for handling rendering so explicitly, I find it quite convenient to set a variable and see the new result rendered automatically (behind the scenes with setter functions in React, or by using the value directly with useRef or Svelte's approach).So that's just my first impression, based on looking at the code:
the method of attaching event listeners looks like a worse Svelte plus I don't like the explicit rendering call for reasons mentioned, but the rest of it bothers me as well - the idea of needing to use seemingly endless function args for children of a component absolutely terrifies me.
Also, the idea of not being able to use basic HTML markup and instead needing to call functions like
div(p("Hello World!"))also absolutely terrifies me. You're incorporating some of the things that I dislike the most about Vue and Svelte - introducing a new API for event listeners that doesn't closely match the HTML spec like React does - while also introducing an arbitrary and less clear way to render HTML elements that none of those other popular libraries use, though I see that you're supporting JSX as well, just with the need to still call functions to access stateful values. Bleh.Obligatory "the totally real React Forget engine will solve most of these problems"™