3 ms·
For the record, an equivalent React component is equally simple: export default () => <div>{1+1}</div>
by tlrobinson 7y ago
For the record, an equivalent React component is equally simple:
export default () => <div>{1+1}</div>
- RobertRoberts 7y agoNow try and run that in a browser. This is neither valid JS or HTML.
- JMTQp8lwXL 7y ago> export default () => <div>{1+1}</div> is export default function () { return React.createElement('div', null, 1 + 1) }; If your concern is for beginners, I can appreciate that. But for anybody developing an enterprise grade application, using a transpiler isn't an appreciable barrier to entry. For beginners, there's create-react-app, vue cli, and angular cli. So you can get started immediately, without even knowing what a transpiler is.
- RobertRoberts 7y agoWhile I risk starting a pointless argument my readings about React have been that it's only javascript functions. But in reality it's a DSL. I have never read anyone bragging about DSLs in javascript. So react's marketing seems dodgy. Also is Babel a transpiler or compiler for JSX? And is React useful without JSX?
- deleted 7y ago[deleted]
- tlrobinson 7y agoCall it what you want. The point is instead of inventing an entirely different template language, JSX adds a little bit of HTML/XML-like syntax to JavaScript. You use regular old JavaScript operators and functions for things like conditionals and loops. You don't have to use JSX with React, but the vast majority of people do, because they aren't dogmatic about it not being "pure" JavaScript or whatever.
- RobertRoberts 7y agoLook at this from an outsiders perspective. React's marketing says "It's just javascript", but it's not. I don't take issue with how React works, I take issue with how it's being presented to new users and outsiders.