News for hackers. Stuff that matters.
Re:React as a UI Runtime by Bahamut on Sunday February 03, 2019 @01:04AM (#19068127)
Just to correct this a bit, while this is certainly true of AngularJS, this is certainly not true of Angular. Angular since v2 has taken a reactive approach throughout, and even the two-way data bing is just syntactic sugar for an evented pattern powered by rxjs. Perf-wise, other than initial load, Angular is actually a little better from my understanding & based on numbers I’ve seen.

React has certain weaknesses that aren’t seen in other UI libraries/frameworks as well - forms are a complete mess to work with, even with formik, and animations are pretty problematic.

As with anything, there are tradeoffs to approaches. FB isn’t as form heavy in general, so optimizing how it works for the rendering inputs from external sources & dev usability makes sense for their use cases. It’s important not to conflate this by overpraising.

Re:React as a UI Runtime by mds101 on Sunday February 03, 2019 @01:11AM (#19068141)
> forms are a complete mess to work with

Could you elaborate on this? I've been creating form heavy react apps for a couple of years now and haven't really come across anything that would make it 'a mess'.

Re:React as a UI Runtime by fiddlerwoaroof on Sunday February 03, 2019 @01:45AM (#19068200)
I find that the biggest issue with forms and react is attempting to use lifecycle methods and local state to manage the behavior of the controls: at work, I’ve done a bunch of refactorings to replace local state and lifecycle methods with redux and logic in the render method of the parent components, and this has always led to simpler components and has fixed a lot of bugs caused by inconsistencies between props and state.
Re:React as a UI Runtime by bgdam on Sunday February 03, 2019 @03:20AM (#19068422)
I think this is because you are using both state and props to manage the values of fields. I generally tend to use only props, with an onChange handler passed in from the parent component. This way, I can always have an up to date mapping of field names to values in the parent component, while simplifying state management in the child.
Re:React as a UI Runtime by fiddlerwoaroof on Sunday February 03, 2019 @06:41AM (#19069074)
This is exactly what I’m saying: use only props and handle state elsewhere.
Re:React as a UI Runtime by jordic on Sunday February 03, 2019 @03:08AM (#19068392)
You made not need redux! Found lot's of projects where they plug redux an turns the project a completly mess. (connected components everywhere), actions to manage local component ui state..
Re:React as a UI Runtime by danabramov on Sunday February 03, 2019 @04:04AM (#19068523)
I’ve heard people are pretty happy with Formik.

https://jaredpalmer.com/formik/

Re:React as a UI Runtime by latchkey on Sunday February 03, 2019 @05:59AM (#19068928)
You're right Dan, this is a great framework, but the code complexity behind it is insane. Of course a lot of that complexity is due to HTML/browser, we cannot ignore that.

However, part of that complexity is the fault of React. The choice of HOC vs. Component... two ways to do the same thing. There is also FastForm vs. Form. As we move on over time, now we have hooks being added as well. The mental complexity just to put a simple input on a page is overwhelming.

I think what I'm looking for is React to take some ownership and provide guidance out of the box for these core browser features under the React umbrella.

Re:React as a UI Runtime by quantummkv on Sunday February 03, 2019 @08:26AM (#19069444)
> I think what I'm looking for is React to take some ownership and provide guidance out of the box for these core browser features under the React umbrella.

So we need React on Rails? An opinionated collection of libraries that work on top on the React Runtime. I personally find this idea compelling.

Re:React as a UI Runtime by latchkey on Sunday February 03, 2019 @09:07AM (#19069603)
There are a few of these sorts of things already. I'm not really talking about opinionated frameworks (or collections of various github projects stuff into a big meta project). https://reactjs.org/community/starter-kits.html

What I'm talking about is something more akin to this statement: https://angular.io/guide/forms-overview "Handling user input with forms is the cornerstone of many common applications"

Re:React as a UI Runtime by quantummkv on Sunday February 03, 2019 @10:17AM (#19069986)
But isn't that something React wants to avoid? I remember reading somewhere that React does not want to recommend any approach to forms, routing, etc., but leave it to the user.
Re:React as a UI Runtime by machiaweliczny on Sunday February 03, 2019 @11:53AM (#19070634)
Vue is just like that. Actually from 3.0 it might be better than React.

Styling is handled out-of-the-box. Reactiveness will be glitch free with proxies and it will have TS support.

(Disclaimer: I use React right now)

Re:React as a UI Runtime by danabramov on Sunday February 03, 2019 @09:29AM (#19069701)
I mean, I don’t think it’s designed to “put an input on the page”. Tracking things like hover, dirty and pristine states, sync and async validation, etc, is an inherently complex problem.

If you just want to put an input on the page, that’s just three lines with React. (Especially with Hooks.)

Re:React as a UI Runtime by latchkey on Sunday February 03, 2019 @11:10AM (#19070354)
Reading the documentation again, I just remembered this page:

https://reactjs.org/docs/forms.html

Makes my point (happily) moot. You're right. Sorry for the trouble.

Re:React as a UI Runtime by fiddlerwoaroof on Sunday February 03, 2019 @06:43AM (#19069081)
I think redux is the only thing that can prevent a react project from becoming a mess: I’ve noticed that the major bug points in the app are where people try to use something else to manage state