Live data from Hacker News

An experienced Javascript developer’s account of learning React

medium.com

51–60 of 157 posts

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

#51
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 had the same experience. It took me about a week to "get" Redux as a new-ish dev back a year or so ago. Why do you think people have trouble with it?

> It took me about a week to "get" Redux

You hit the nail on the head. Devs these days get frustrated if it takes more than an hour.

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

#52
His point about React Native at the end is very reductive.

As an experienced (6+ years) iOS developer, my experience putting together a dual platform app in React Native has been very positive. For the majority of content driven apps, it seems to me that React Native is a no brainer.

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

#53
In general the React approach works best if you are willing to build out a handful of utilities on your own sometimes, rather than always choosing from pre-existing open-source solutions. You don't need React Router. You don't need React-Redux. Heck, you don't always need Redux, you can just throw a state object on the window (or make a state module or whatever you do these days).

Here's a React 15 app in a single HTML file, using ES5 and the old in-browser JSXTransformer:

https://gist.github.com/guscost/27736c5f0913184695492ac40fd3...

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

#54
The stampede to React has probably gone too far but it was very much a reaction to the domination of Angular which from personal experience had made web development a nightmare.

React proved you didn't need a huge overbearing framework to get things done Vue and Riot takes this even further (even if Riot predates React)

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

#55

Why is mixing HTML into your code in PHP bad? Because it mixes presentation and logic. Why is mixing HTML into your code in React good? Because it isolates all the view code for a single component in a single file.

Two things there...

1. If PHP coders did component driven development it might not be so bad, the problem is most PHP apps mix code and HTML in a way that resembles speggeti so we (I've tought a lot of PHP courses) teach separation of concerns as to encourage maintainable code.

2. In React you're not really supposed to (as a matter of best practice) mix presentation and business logic. Typically most components are for presentation only with business logic done via event handlers and props. If you need state you should wrap your display component in a business logic component (typically called a container in the Redux world).

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

#56
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…

If your web-app has even a modicum of complexity on the client side, the vanilla DOM based solution is going to get unwieldy real fast.

Consider a simple list of elements to which you can add or delete items. With vanilla DOM, you’ll have to write handlers that will `$.find` the particular element, and then run a `$.remove` to remove it. To insert something, you’ll have to do a manual `$.appendHTML`. And when you have to send the data over to the server, you have to iterate over the elements, collect it into an array and send it across. But if you used something that had an explicit notion of the application state, and allowed you to express your view as a simple function of your state, all you would have to write is an `array.push` and another `_.remove(array)`. The view will update automatically because we’ve already told the 'over-engineered' framework what to render for any given state.

But you could avoid framework and still not fall prey to spaghetti DOM manipulation. All you need is to keep an explicit state variable and have a single `render` function to deal with the DOM. This method will be invoked everytime you change your state, and it'll recreates the necessary DOM from scratch. It is a simple straight-forward implementation, but now you're going to lose cursor position, and with large enough DOM trees, the lag will be noticeable.

To fix this, you can add a virtual-dom implementation that'll maintain the DOM tree in memory and avoid re-rendering things that haven't changed.. and then you can have some sort of immutability checker to skip even the virtual-dom rendering part. And by now you have a home-brewed over-engineered React-like framework, but without any of its documentation or robustness or community.

We definitely need to be conservative in our choice of tools, but React today is a conservative choice to build rich front-end web applications. More than a framework, it is an approach to user interfaces, and it is a damn good one too.

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

#57
post #24

Earlier quoted context omitted.

I really don't see how jQuery would help you much there. It doesn't provide any sort of common structure at all, and it's nowadays arguably not very helpful for its helpers either.

> write a bunch of code to deal for various browsers jQuery helps here

Out of curiosity, which of these compatibility features do you find most useful?

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

#58
post #48

Earlier quoted context omitted.

It wasn't lifted from the docs. The tutorial is a tic-tac-toe game, while the example in the post is an AddTodo function [edit: there appears to be an add todo section, but the code is completely different]. Furthermore, all the examples in the tutorials show a pattern where you reference functions instead of writing them inside JSX.

Check again. On the homepage scroll down to: > An Application " Using props and state, we can put together a small Todo application. This example uses state to track the current list of items as well as the text that the user has entered. Although event handlers appear to be rendered inline, they will be collected and implemented using event delegation. "

Fair enough - it's a todo app. The code isn't structured in the same manner as the author's, however, so my point stands. It doesn't look like the code was lifted from the docs, as you said, but instead transformed to look like spaghetti.

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

#59

Earlier quoted context omitted.

Sounds like a case of bad developers. Obviously, plenty of sites that use React do just fine. That said, I've had those frustrations at work and wishing in my head that our SPA was a server-rendered app instead.

Sure, but the question that always lingered in my head was, how it even possible to mess up a text box? It was a simple input form that crashed the browser by taking up all its memory. I could literally see my browser GC spike during every single keystroke. If it's possible screw up the most basic element of a website, I shudder to think what other simple elements are out there that are horribly written

Asana (ugh, not my choice) once prompted me for feedback. The whole thing's performance is always worst-in-class god-awful, but the feedback textarea lagged nearly a full second before registering each keystroke. A textarea. A textarea.

My feedback was... a little mean. Having read some of the stuff about their NIH-induced in-house framework I suspect they've got several things hanging around in it that belong on Accidentally Quadratic, assuming they're still using that thing. If they're not still using it then I don't know what they're doing wrong. Possibly most things.

Meanwhile I use Basic HTML gmail because full page reloads are way faster than Ajaxy-Gmail and (especially) Inbox. And those are from a company with "only" "A players". I hate the modern web so very much.

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

#60
post #56
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…

If your web-app has even a modicum of complexity on the client side, the vanilla DOM based solution is going to get unwieldy real fast. Consider a simple list of elements to which you can add or delete items. With vanilla DOM, you’ll have to write handlers that will `$.find` the particular element, and then run a `$.remove` to remove it. To insert something, you’ll have to do a manual `$.appendHTML`. And when you hav…

To be fair diffing virtual dom is not the only way - you could also be diffing the model and only update the parts which need it. Knowing the model well allows you write an efficient diff. The problem of course is that dom diff is universal while model diff is specific to application.
Post reply on HN