3 ms·
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 research
by vmasto 9y ago
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 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-import-react-or-just-component-proptypes-will-do 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 https://github.com/facebookincubator/create-react-app
- gianlucaguarini 9y agoditto https://medium.com/@gianluca.guarini/i-thought-it-was-clear-in-the-article-but-probably-i-will-try-to-argument-it-again-i-am-not-dfc1318d54c7 https://medium.com/@gianluca.guarini/i-thought-it-was-clear-...
- lawik 9y agoI've had really bad experiences trying to get going with React but I just found this article ranty. I was also expecting something more interesting. No feeling of depth to the analysis, just "I did not like this and now I will complain about it". I'm guessing english is not the authors first language so I won't dwell on it but I found it somewhat hard to follow.
- gianlucaguarini 9y agoThanks for your feedback I have tried to fix some grammar and syntax errors. Please ping me in case you find it still confusing
- andrewingram 9y agoI agree on everything except what you're saying about React Router. I've been working on projects that tracked React Router since it was first announced. Understandably, every pre-1.0 release broke something, 1 to 2 broke things, 2 - 3 was compatible but slower in enough scenarios that it's questionable whether you should upgrade. RR4 just isn't the same library, and due to its reduced scope has thrown a few problems back into the realm of being unsolved. It's fairer to say that the year during which RR2 and RR3 were the primary releases, was a relatively stable time. I've generally been pretty tolerant of the amount of library churn within the React ecosystem, I'm the kind of person who will happily keep dependencies up-to-date and upgrade apps to newer/better tools when they emerge (I'd even say I enjoy it more than actual day-to-day coding), but React Router has been a major source of frustration for a long time now. Hopefully, the version 4 API is going to be stable for a while (even though getting efficient data-loading with Relay is now an utter pain).