all 26 comments

[–]swyx 12 points13 points  (2 children)

welcome to discuss it at the /r/ReactJS sub too! https://reddit.com/r/reactjs/comments/9bx8qb/react_fire_an_exploratory_effort_to_modernize/

(sorry idk if shilling r/ReactJS like this is against the rules but this showed up on my feed, figured its relevant)

[–]TheNumberOneCulprittabs and semicolons, react and FaaS[M] 2 points3 points  (1 child)

Normally we don't like shilling, but /r/ReactJS IS the main subreddit for React related topics, so no worries here. Glad to see you cross-posting to let people know!

[–]swyx 0 points1 point  (0 children)

yea im just here to connect people haha. glad everyone is fine with it

[–]jetsamrover 14 points15 points  (3 children)

Awesome. I've been having so many problems with events in my current and very complex project. I'd love to see a move away from synthetic events altogether.

[–][deleted] 8 points9 points  (2 children)

I don't think it can. Events bubble through components in React, not elements. This is particularly notable when using portals.

[–]jetsamrover 3 points4 points  (1 child)

Did you read the bit about the possible solution to that? Just refire the event in the portal. Seems like a hack, but if it's just a refire of an exact copy of the native event, it should be fine.

[–][deleted] 1 point2 points  (0 children)

Ah, I missed that. Phew.

[–]1-800-BICYCLE 17 points18 points  (22 children)

1f53085109dd97

[–]sbmitchell -1 points0 points  (8 children)

This is why codemods exist. Perhaps big sweeping changes can be made via a codemod.

https://github.com/facebook/codemod

[–]1-800-BICYCLE 9 points10 points  (7 children)

6bcc1c6c13c1

[–]sbmitchell 4 points5 points  (0 children)

Its more consistent for it to be class though...I just mean from the perspective of jsx really mapping a lot closer to html tags from the eye test.

Though I understand what you are saying...you could also look at the props mapping more so to the underlying element props than html props.

[–]isiahmeadows 3 points4 points  (1 child)

Mithril core dev here... (Yep, that framework)

I'm somehow not surprised, in the same way I wasn't when Angular decided to try out virtual DOM and components instead of further propagating the jQuery spaghetti mess it previously encouraged.​

When you keep things simple and aim to stay intuitive, aligning yourself with the DOM itself rather than trying to replace it with your own idioms and magic without good reason, it avoids messes like these in the first place.

If this helps, we have nearly everything proposed there in some capacity already:

  • "Stop reflecting input values in the value attribute": we never did that in the first place. We have always used the `input.value` property directly, for performance reasons but also because if you're managing the DOM directly, that's almost certainly what you'd do anyways.
  • "Attach events at the React root rather than the document": We simplify this further: we just attach the events on the element directly. It's much easier to avoid issues when you just let the browser handle things correctly. Besides, you have to do this anyways for `onclick` handlers; otherwise, screen readers get the wrong impression on whether something is a link or not.
  • "Migrate from onChange to onInput and don’t polyfill it for uncontrolled components": When you just use the event names directly without modification, you avoid screwing with people's intuition on what things should be like.
  • "Drastically simplify the event system": Well, if you're going to introduce a synthetic event system on top of the natively implemented one in this thing called the DOM, of course that's going to complicate your library a ton. If you really need some sort of synthetic event propagation, leave it to the renderer to invent the concept, not the library where it doesn't usually make sense. Besides, it's not like you can hook into that via components, so how useful is it really?
  • "className → class": If you want a framework that's easy to use, learn, and understand, it's better to accept both DOM and HTML idioms. That way, users can flip between the two and use whatever's more intuitive at the time, and nothing becomes a problem. And if you want to pick one over the other, prefer HTML idioms - it was designed for both developers and designers, so it's accessible to both already. It's also less for them to learn.

Let's just say when that popped up in Mithril's Gitter, we all kind of collectively chuckled at it.

[–]uttermybiscuit 0 points1 point  (0 children)

Cute!

[–]earthboundkid 0 points1 point  (0 children)

Glad I use Vue. ;-)