Live data from Hacker News

An experienced Javascript developer’s account of learning React

medium.com

31–40 of 157 posts

Re: An experienced Javascript developer’s account of learning React

#31
post #2

React popularity seems to me the result of wrongly-headed thinking: that because facebook is popular, any technology behind it must be good, and because react is popular (allegedly), react must be good. I've always been very sceptical of react, and I'm glad I didn't invest too much time looking into it, as it seems both a time sink and a boilerplate-filled approach. I wonder why some people like it, writing no-framew…

>writing no-framework javascript isn't difficult at all,

If anyone recommends this without any concrete source code to illustrate the superiority of the advice, be skeptical for 2 reasons:

1) the programmer who rejects frameworks ends up writing another invisible framework that doesn't happen to have a name. Because the author is intimately familiar with his own code, he many not even realize that an implied framework emerged from it.

2) the programmer truly avoided coding an "accidental framework" but only by duplicating code everywhere.

In short, if you organize code in any coherent way with consistent abstractions to follow principles of DRY[1], it becomes a framework whether you give it a name or not.

It doesn't mean the framework-called-React is perfect. What it does is raise the quality of discussion from "plain JS is better than ReactJS" to the more realistic comparison of "my unnamed-framework is better than React-framework because ... see my source code at github, etc".

>I wonder why some people like it

I think for some, they truly chose it for the wrong reason. However, there are others who look at the problems React solves (efficient DOM diffing algorithm, 1-way view update, etc) and conclude that they would rather not reinvent that themselves. Therefore, they use React so they can start solving other more specific problems relevant to their business domain.

[1] https://en.wikipedia.org/wiki/Don%27t_repeat_yourself

Re: An experienced Javascript developer’s account of learning React

#32
post #20

I am confused why people think Redux is complicated. Maybe you were trying to use React-Redux? Redux itself seems incredibly simple to me, so simple that I sometimes wonder if I need a library for the functionality at all. This "Redux in a nutshell" sums up the simplicity nicely I think: https://gist.github.com/MarcoWorms/30758235f05faec844b8c06ce...

I've never been any good at frontend work. Everything I've made has always gotten messy, fast, and eventually it's an unmaintainable mess.

React-redux just made it all cleaner, easier. There was a nice tight constraint on what I could do- want something to happen? Call an actionCreator, let the action change the state, re-render. Constraints free you.

The last four months have suddenly seen me shift from 'leave UIs to the devs who can do that' to 'Oh, we need a whole new page to show some reports? I'll have it done today'.

Re: An experienced Javascript developer’s account of learning React

#33
post #29

At our company, we have banned React, Angular and other "overengineered" JS frameworks. Our HTML is rendered from a standard boring Groovy server page, with some vanilla-js for DOM manipulations here and there. We have hired developers that were React fans, which quickly changed opinion that this old-school way for developing web applications is indeed better. It is faster to code, an order of magnitude easier to mai…

Angular/Angular4 is a joy to develop with, so that's too bad you're limiting yourselves artificially.

We have groovy in my stack at work and everyone despises it. Fortunately that's a legacy we're moving away from.

Re: An experienced Javascript developer’s account of learning React

#34

Earlier quoted context omitted.

I am not a js dev, but isn't the issue of no-framework that you have to write a bunch of code to deal for various browsers? And a bunch of more code to deal with basic web patterns that you'll end up copying from project to project?

I don't see where the parent suggested no framework. It's likely he or she prefers working a different framework or library, like vue.js or even jQuery. For me, jQuery is the bare minimum requirement. I would never attempt to write a large app in pure JS, even with babel. You would definitely run into some of the problems you mentioned. EDIT: I see now where he mentioned no-framework JS

I have written relatively large (35k lines) project in pure JavaScript (without even jquery) and have never faced any of the issues mentioned by the parent, (Babel helped). I write native first and then run babel to appease my older browser faring users.

The advantages of native are that it's extremely snappy to use and fast to load. Bears smaller memory footprint (have to use angular.js at work and god it's awful) and with newer things like async await, ES16 classes, etc code management is very good. Can't recall the last time I had to take care of a specific browser quirk.

Re: An experienced Javascript developer’s account of learning React

#35
post #22

Earlier quoted context omitted.

In his example in the pre-preface there was quite a big amount of logic.. I don't really see the point in your post looking at that code.

You can have complex logic and functions in JSX but that doesn't mean that you have to, so the example is very contrived. That way of writing the code is completely discouraged in the documentation and I haven't run across it often or at all in the real world.

The example in the article was lifted from the front page of the official React website [0].

[0] https://facebook.github.io/react/

Re: An experienced Javascript developer’s account of learning React

#37
post #29

At our company, we have banned React, Angular and other "overengineered" JS frameworks. Our HTML is rendered from a standard boring Groovy server page, with some vanilla-js for DOM manipulations here and there. We have hired developers that were React fans, which quickly changed opinion that this old-school way for developing web applications is indeed better. It is faster to code, an order of magnitude easier to mai…

Just curious, how do you handle the vanilla-JS stuff?

1) inline with your view files

2) write them in separate js files and include them depending on the page

3) concat them into one big js file which gets included on every page

4) something else?

Re: An experienced Javascript developer’s account of learning React

#38
post #29

At our company, we have banned React, Angular and other "overengineered" JS frameworks. Our HTML is rendered from a standard boring Groovy server page, with some vanilla-js for DOM manipulations here and there. We have hired developers that were React fans, which quickly changed opinion that this old-school way for developing web applications is indeed better. It is faster to code, an order of magnitude easier to mai…

Might I ask what kind of applications you're developing?

While I generally like the idea of doing web applications the old-fashioned way depending on the requirements manipulating the DOM using vanilla JavaScript can quickly get out of hand.

Re: An experienced Javascript developer’s account of learning React

#40
I was very intrigued by the title:

Things nobody will tell you about React.js

Immediately had high hopes that someone is going to try and give a well researched, novel critique that maybe can spur out some constructive conversation.

And then, sadly, the author goes on to write exactly what countless other articles have already covered and discussed to the death for years now. "HTML in JS", "JSX is bad", "Redux is complicated", "The tooling is too much". And then here we are again in the front page of HN for some reason.

To me, this is, again, an extremely common case of "trying to learn everything at once".

Still, a couple of points I'd like to try to mention:

JSX: Has been argued about so much it's pretty much useless to try and add anything to this discussion at this point honestly. For whomever likes it, fine, for those who don't, thankfully the JavaScript ecosystem provides with a multitude of alternatives. For new-comers still trying to reason about it, this talk by Pete Hunt is a good start https://www.youtube.com/watch?v=x7cQ3mrcKaY

Redux:

> Anytime I work with redux I need to go back to its documentation because its core concepts are so complicate that my mind struggles retrieving them back puking them out as soon as I stop working with it.

While I agree that working with Redux at scale can be complicated, the core concepts are extremely simple: Async Action -> Action -> Reducer -> Connect data to your components -> Display -> Async Action -> enter an extremely simple data flow paradigm (flux).

(state, action) => state

Redux can get complicated when you add to the mix schemas, normalization, selectors et al. My advice and I can't stress this enough: Don't try and learn everything at once, start with simple core concepts, iterate later, add tiny new pieces when it makes sense. You don't always need Redux anyway.

RE: Redux boilerplate: It's a lot, yes, but that's by design. Redux is simply a tradeoff between boilerplate and repetitive, dead simple management of your complicated state. I'd rather write a few lines of code more if it means I'd avoid having logic bugs or getting confused where my data comes from.

RE: React Router:

[...] the maintainers had the great idea of bumping 3 major versions in 5 months completely not backward compatible to each other

This is simply not true. React Router has had a single major breaking API change in 2 years. RR 2 and 3 where the same thing and 4 has just now been released after 2 years of stability.

RE: Final complaints:

[...] you must use className instead of class to define the DOM css classes

This is an extremely weak point to complain about.

[...] you will need to import in your scripts react-dom and react without never using the last one instance for some wild reason known only by the React team

You only need react-dom once, to the point where you ReactDOM.render your application. You need React because you're using it implicitly with JSX. I'm not on the React team by the way, it's a simple google search: http://stackoverflow.com/questions/38206646/do-we-need-to-im...

[...] you can render functional components just by using js functions but you will need to wrap all your markup always in a wrapper tag to properly allow the Virtual DOM creation

Valid point, although it's a nitpick. In any case, this is going away with the newer version of React's reconciler (Fiber).

[...] its apparent simplicity is hidden behind a whole toolchain you need to configure before you can even writing 1 line of code

create-react-app is great, officially supported, and does everything, is it the fault of the ecosystem that the author is reluctant to try the official CLI?

https://github.com/facebookincubator/create-react-app

Post reply on HN