News for hackers. Stuff that matters.
Re:Things every React.js beginner should know by arethuza on Monday January 25, 2016 @08:19AM (#10966981)
Isn't that because it's really JSX?

https://facebook.github.io/react/docs/jsx-in-depth.html

[NB Not that I know, just checking my own understanding].

Re:Things every React.js beginner should know by lucaspiller on Monday January 25, 2016 @09:14AM (#10967242)
Yes, the JSX is compiled (or "transformed") to JavaScript which creates components internally in React:

https://babeljs.io/repl/#?experimental=true&evaluate=true&lo...

I felt the same as OP when I first started using React, although it makes more sense now I've played with it, I'm still not sure about mixing concerns (code and view) in the same file. Especially when you start talking about CSS too...

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

Re:Things every React.js beginner should know by pkrumins on Monday January 25, 2016 @09:50AM (#10967431)
I hadn't heard about JSX before so I went to your link to check it out. This is just one of the most off-putting introductory statements I've ever read:

    JSX is a JavaScript syntax extension that looks similar to XML.
Don't we all hate XML? How can you possibly even go on reading about this technology further if it's introduced like that.
Re:Things every React.js beginner should know by clay_to_n on Monday January 25, 2016 @10:04AM (#10967507)
XML is still used as a the standard for building layouts - on the web and on Android, and probably many other places. It can be much more readable than code for nesting components.

I believe people hating XML has more to do with using XML as a data transfer format, right? I'm happy using XML for Android layouts but can't imagine using it as a replacement for JSON - which I think is where most of the hate comes from.

Re:Things every React.js beginner should know by pkrumins on Monday January 25, 2016 @10:08AM (#10967533)
Good point - Now that you said that, I don't mind using XML for defining UIs but I absolutely hate to use for data transfer.
Re:Things every React.js beginner should know by untog on Monday January 25, 2016 @10:08AM (#10967537)
XML is fine. XHTML is XML, after all. The issues with XML are the kind of XML that is often created with it, with namespace nightmares, endless embedded tags, etc. etc.

But if you're using XML to basically make a variant of HTML, it's great.

Re:Things every React.js beginner should know by pkrumins on Monday January 25, 2016 @10:11AM (#10967556)
They should've said:

    JSX is a JavaScript syntax extension that looks similar to HTML.
Re:Things every React.js beginner should know by EvanPlaice on Monday January 25, 2016 @09:10AM (#10967227)
JSX is a HTML-like template language that gets preprocessed to actual HTML.
Re:Things every React.js beginner should know by Guillaume86 on Monday January 25, 2016 @10:09AM (#10967540)
No it's not getting preprocessed to actual HTML in React. Depending on the transform function, it can be turned to an object tree or a function calls tree (like in React) or actually HTML like you said but it's not a common use case AFAIK.

It's not a text templating language like classic PHP, it's an object/function calls hierarchy DSL (more like vb.net XML literals). I think most people critisizing react for putting html in JS havn't tried it or don't remember why "html" in code was considered bad in the first place.

Re:Things every React.js beginner should know by EvanPlaice on Tuesday January 26, 2016 @02:47PM (#10975476)
Right. I was aiming for the 'simple' answer but should have said DOM instead of HTML.

I'm also thinking in more of an Angular2 context as that's what I'm most familiar with.