Live data from Hacker News

Learning Node.js and React while building a product

javascriptkicks.com

21–30 of 42 posts

Re: Learning Node.js and React while building a product

#21
post #3

Hmm. So, the complaints about React are "no convention over configuration", "we didn't like JSX", "event handlers require binding for `this`", and "trouble finding a correct source of truth" for articles and such. The first two are pretty common. Some people _love_ that React lets you pick and choose the other pieces that you need for your own application, while others hate that React isn't a kitchen-sink-provided fr…

Agreed. The main complaint is just "I want a framework and I chose a library." JSX isn't even required either. It just desugars into: React.createElement(elementClassorString, props, children); If they want to use their own function for that... they can, but JSX is a trivially easy way to describe nested components (which can get verbose with the above). A nice bonus of JSX is that it also means your components and r…

I find it a bit odd that both you and the parent commenter (acemarke) seemed to have interpreted the post in a completely different tone than I did.

I didn't find anything in the original blog post in the tone of a "complaint". If anything, they were merely pointing out what kind of things they run into and their thoughts, while transitioning from an ASP.NET background.

It's actually a really helpful read if you also happen to come from ASP.NET and are looking to pick up the Node/React stack. I personally also came from a different stack only recently (not ASP.NET) and dove into Node/React a few months ago, and found the way he expressed his views helpful for myself to align my thoughts.

Re: Learning Node.js and React while building a product

#22

You don't have to use 'this' at all in React. I've written about it here: https://medium.com/@baronmaximilianwilleford/react-without-t... I never use 'this', 'bind', 'apply', 'call', 'class', and only use 'new' to create React components. I find it much easier and more fun to work with React as a result. I hope other people would give it a try.

i'm going to give this a try, thanks!

Re: Learning Node.js and React while building a product

#23
Pretty interesting read. I have had pretty much the same experience with documentation around react, and although Angular 2/4 documentation can be confusing at times at least you know what you are reading isn't outdated. Also as far as their backend choices I'd like to know why they went with knex over sequelize.

Re: Learning Node.js and React while building a product

#24
post #21

Earlier quoted context omitted.

Agreed. The main complaint is just "I want a framework and I chose a library." JSX isn't even required either. It just desugars into: React.createElement(elementClassorString, props, children); If they want to use their own function for that... they can, but JSX is a trivially easy way to describe nested components (which can get verbose with the above). A nice bonus of JSX is that it also means your components and r…

I find it a bit odd that both you and the parent commenter (acemarke) seemed to have interpreted the post in a completely different tone than I did. I didn't find anything in the original blog post in the tone of a "complaint". If anything, they were merely pointing out what kind of things they run into and their thoughts, while transitioning from an ASP.NET background. It's actually a really helpful read if you also…

Yeah, re-reading it, the tone was a bit more "things we ran into" then "stuff we hated". That said, the items listed are definitely common complaints or points of argument about React that I've seen numerous times, so I was coming at it from more of that reaction.

Re: Learning Node.js and React while building a product

#25

Earlier quoted context omitted.

Hey @acemarke, thanks for the comment! For myself, I still have not decided whether I like JSX or not :) My colleague finds it great, and I like the declarative nature of it, just need to persuade myself to accept it mixed in JS file. Yes on .bind, but I got used to not having to care about it in Aurelia (and Angular also). Got my fair share of `this` handling in pre-ES6. And of course, thank you for the links. Bookm…

I've found that the best way to make event handlers is instead of doing class Blah { private handleThing(...) {} } to instead do this class Blah { private handlething = (...) => {} } this means that it is created only once, at instantiation of the component, so it is fast, looks decent, and has access to `this` as it's technically a method on the object, not the class. Also, if you're coming from C# land, head straig…

Yep, the class property syntax helps with event handlers.

As for C# and TypeScript, we also have a very strong JavaScript background, from vanilla pre-ES6 to the latest ES2017+. We still prefer JavaScript to TypeScript, although out of languages that compile to JS, TypeScript is the best in our opinion.

Re: Learning Node.js and React while building a product

#26
post #11

Earlier quoted context omitted.

Hey @acemarke, thanks for the comment! For myself, I still have not decided whether I like JSX or not :) My colleague finds it great, and I like the declarative nature of it, just need to persuade myself to accept it mixed in JS file. Yes on .bind, but I got used to not having to care about it in Aurelia (and Angular also). Got my fair share of `this` handling in pre-ES6. And of course, thank you for the links. Bookm…

> just need to persuade myself to accept it mixed in JS file Why is this a bad thing? The most important thing about JSX is that it's a single source of truth -- you never have to wonder if data is processed in the JS or in the template. I really think everything in one file is the ideal, we've even started moving the styles inline via styled-components.

Not a bad thing. Just a personal preference of trying to separate views and view models for a long time. I believe it just needs some time to get used to it. As I said, I really do like declarative nature of JSX, knowing that it's just compiled to a regular JS/DOM code.

Re: Learning Node.js and React while building a product

#27

Earlier quoted context omitted.

Are you using arrow functions? I find that using es2015 arrow functions for class methods takes care of most of the problems around this and react. The only annoyance is dealing with binding event handlers to items/components in a list. Generally you need to abstract the list item into it's own component and do the event handler binding there. I don't use .bind() anywhere in my react code.

Yep, we are using arrow functions and other ES2015+ goodies, but they don't help with event handlers. In fact, I believe class property syntax helps with that, but we only figured it out after we built these few pages and components necessary for the web app part.

>Yep, we are using arrow functions and other ES2015+ goodies, but they don't help with event handlers.

They do. Just do:

  myHandler = (v) => {
    ...
  }
and you don't need to bind in the constructor anymore. You'll need to use Babel of course to transpile that.

Re: Learning Node.js and React while building a product

#28
post #10

Earlier quoted context omitted.

One note: From what I've read, using arrow functions as props in a render method of a component will create new functions each render, so you might end up with a good bit more GC than normal. There are some nice little mix-ins that will autobind to remove the need to remember to .bind everything.

Nowadays you can just stick a class property anywhere in your React component: handleSomething = (params) => { ... }; and the use it in your render function like this without any binding:

Yes, class properties are the way to go.

Re: Learning Node.js and React while building a product

#29
post #21

Earlier quoted context omitted.

Agreed. The main complaint is just "I want a framework and I chose a library." JSX isn't even required either. It just desugars into: React.createElement(elementClassorString, props, children); If they want to use their own function for that... they can, but JSX is a trivially easy way to describe nested components (which can get verbose with the above). A nice bonus of JSX is that it also means your components and r…

I find it a bit odd that both you and the parent commenter (acemarke) seemed to have interpreted the post in a completely different tone than I did. I didn't find anything in the original blog post in the tone of a "complaint". If anything, they were merely pointing out what kind of things they run into and their thoughts, while transitioning from an ASP.NET background. It's actually a really helpful read if you also…

> I didn't find anything in the original blog post in the tone of a "complaint". If anything, they were merely pointing out what kind of things they run into and their thoughts, while transitioning from an ASP.NET background.

Yes, exactly this! There's nothing to hate really. It's more of a complaint against our inability to quickly grasp new concepts than trying to throw some stones over to React.

Re: Learning Node.js and React while building a product

#30

Pretty interesting read. I have had pretty much the same experience with documentation around react, and although Angular 2/4 documentation can be confusing at times at least you know what you are reading isn't outdated. Also as far as their backend choices I'd like to know why they went with knex over sequelize.

Thanks! I guess we just run into knex first, found out it works nicely in our app and continued to use it.
Post reply on HN