News for hackers. Stuff that matters.
Re:A Primer for Building Single Page Applications with React by matthewmacleod on Tuesday March 24, 2015 @07:42AM (#9255954)
I do undestand where you come from there, but I'd view this as a bit different.

React's building block is the 'component' – the idea being that this is an isolated part of the application. By its very nature, isolating a component means separating the HTML from all the other HTML, and the script from all the other script.

Since components are generally quite small, it makes sense to bundle these together. You don't suffer the problems that encouraged people to separate concerns in the first place (things like have loads of interacting code that's duplicated and closely tied to structure), so it's OK to take a different approach – and I must say, in practice it works really well.

CSS is a separate issue – React doesn't mix CSS into the pot at all.

Re:A Primer for Building Single Page Applications with React by masklinn on Tuesday March 24, 2015 @09:35AM (#9256416)
> CSS is a separate issue – React doesn't mix CSS into the pot at all.

Not quite true, ReactNative does, React supports it[0] and one of the lead devs (vjeux, gave the reactjs conf 2015 keynote) has a presentation on doing exactly that[1] alongside being the lead dev on Facebook's css-layout (which IIRC underlies ReactNative's layouting)

[0] https://facebook.github.io/react/tips/inline-styles.html

[1] https://speakerdeck.com/vjeux/react-css-in-js

[2] https://github.com/facebook/css-layout/graphs/contributors

Re:A Primer for Building Single Page Applications with React by philbo on Tuesday March 24, 2015 @08:26AM (#9256125)
Do people generally write tests for these components? I'm wondering how the marrying of presentation and logic affects that.
Re:A Primer for Building Single Page Applications with React by masklinn on Tuesday March 24, 2015 @09:42AM (#9256452)
> Do people generally write tests for these components?

Sure. React even ships with testing utilities to make that easier: http://facebook.github.io/react/docs/test-utils.html

> I'm wondering how the marrying of presentation and logic affects that.

Depends on the exact component. For pure components as part of bigger applications it's really quite easy, just render the component with a known dataset and see if it's got everything where things should be. Then again, that's similar to testing templates… most people don't really test their templates.

For self-contained "widget" components things are a bit harder, it's similar to testing DOM-based widgets really.