Live data from Hacker News

A Primer for Building Single Page Applications with React

github.com

91–100 of 145 posts

Re: A Primer for Building Single Page Applications with React

#91

Earlier quoted context omitted.

But if these individual components share any code between them, you'd still have to write the same lines over and over again for each component. So, how do you reason about that?

There is no reason that components can't share code. It's just JavaScript. Extract common code into libraries, mixins or even components. For example, we frequently create generic containers that modify the behavior of the child or parent. One example is a container that automatically sets its children to be "sticky" once you scroll past it. Another common parent is one that renders it's children is a modal (lightbox…

So you guys are basically defining a new inheritance model in your app, right?

Re: A Primer for Building Single Page Applications with React

#92

Earlier quoted context omitted.

There is no reason that components can't share code. It's just JavaScript. Extract common code into libraries, mixins or even components. For example, we frequently create generic containers that modify the behavior of the child or parent. One example is a container that automatically sets its children to be "sticky" once you scroll past it. Another common parent is one that renders it's children is a modal (lightbox…

So you guys are basically defining a new inheritance model in your app, right?

It's not inheritance at all. The code sharing is across interface boundaries, not like inheritance where, say, changing a member variable can break descendant classes. Instantiating a component is just like declaring a variable.

Re: A Primer for Building Single Page Applications with React

#93
post #86

There's a tutorial bubble for these frameworks and languages. Too little to say, too much reexplanation of the basics. You end up reading for days and knowing less than what you would know if you started playing with the tools.

I dunno, I prefer going through a basic list / hello world tutorial first, and then experimenting.

Re: A Primer for Building Single Page Applications with React

#94

Earlier quoted context omitted.

I've actually never found myself more productive than with React, by a long shot. The reasons why mixing them together makes sense are above us in the thread, but I'd highly recommend vjeux's presentation on CSS in JS: https://speakerdeck.com/vjeux/react-css-in-js I have apps in production with it you can look at the code to as well: https://github.com/reapp/hacker-news-app

vjeux's presentation only applies to a very specific use case at his org namely FB. I should not imitate him just because of the fact that it fitted or served FB right. We should think on our own and figure what works for us and not blindly follow FB's or any other org's lead. Re productivity, if it works for you, good for you but please don't attempt to reinterpret/bend the rules that are well established in the ind…

I am curious, what concerns are not being separated? You have presentation markup with presentation logic. Actually it seems to me the concerns are being brought closer together.

Or are you making artificial boundaries between declarative and imperative code?

Re: A Primer for Building Single Page Applications with React

#96
post #87

it's funny how for years i heard how bad CFML was because of mixing in logic and presentation in custom tags. now for some reason react makes this cool. we've come full circle.

Software is a fashion industry.

So does mean I can start sporting a mullet and bell-bottoms to work to code in VB?

Re: A Primer for Building Single Page Applications with React

#97

Earlier quoted context omitted.

So you guys are basically defining a new inheritance model in your app, right?

It's not inheritance at all. The code sharing is across interface boundaries, not like inheritance where, say, changing a member variable can break descendant classes. Instantiating a component is just like declaring a variable.

So, you're getting rid of inheritance altogether and settling for this interface boundary sharing notion?

Re: A Primer for Building Single Page Applications with React

#98

Earlier quoted context omitted.

vjeux's presentation only applies to a very specific use case at his org namely FB. I should not imitate him just because of the fact that it fitted or served FB right. We should think on our own and figure what works for us and not blindly follow FB's or any other org's lead. Re productivity, if it works for you, good for you but please don't attempt to reinterpret/bend the rules that are well established in the ind…

I am curious, what concerns are not being separated? You have presentation markup with presentation logic. Actually it seems to me the concerns are being brought closer together. Or are you making artificial boundaries between declarative and imperative code?

I'm OK with presentational markup co-existing with logic but to be honest I prefer it the template way not the other way around where the markup is the guest at the JS file.

But throwing CSS declarations to the mix is just too much for me. Now I'll have to maintain markup/presentation/logic in the same place, that's a nightmare and ticking bomb IMHO.

Re: A Primer for Building Single Page Applications with React

#99
post #66

Earlier quoted context omitted.

> You seem to focus only on the few drawbacks of CSS inheritance and to ignore its biggest advantages like you don't have to write declaration for every and each element on the page and rely instead on inheritance for props to cascade properly. This presentation explains what problems React inline CSS solves. https://speakerdeck.com/vjeux/react-css-in-js EDIT: I gave wrong presentation link initially.

This presentation explains what problems React inline CSS solves Could you please summarize in a few sentences what are these probs this approach deem to solve? Because I have seen demos and talks from React people and I was appalled at their neglect of best practices and bending the rules just to push their product and technologies on the community

Why are you looking at this as "bending the rules" instead of as creating new rules for a new way of building web applications? Just hand-waving "best practices" doesn't actually mean that something is best practices if someone else comes up with a better practice.

Re: A Primer for Building Single Page Applications with React

#100

Earlier quoted context omitted.

It's not inheritance at all. The code sharing is across interface boundaries, not like inheritance where, say, changing a member variable can break descendant classes. Instantiating a component is just like declaring a variable.

So, you're getting rid of inheritance altogether and settling for this interface boundary sharing notion?

Yes, we generally only use mixins. Classical OO inheritance causes coupling problems that composition doesn't.
Post reply on HN