4 ms·
Something like this? https://gist.github.com/gaearon/6668a1f6986742109c00a581ce704605 https://gist.github.com/gaearon/6668a1f6986742109c00a581ce70...
by edwinvdgraaf 8y ago
Something like this? https://gist.github.com/gaearon/6668a1f6986742109c00a581ce704605 https://gist.github.com/gaearon/6668a1f6986742109c00a581ce70...
- wa1987 8y agoThat’s without JSX. Transpilation is required in order to make use of JSX.
- whyevenbother 8y agoSo what? You can use React without JSX.
- akhilcacharya 8y agoUsing the createElement structure is more annoying than just doing a es6 template string in Vue.
- whyevenbother 8y agoMoving the goalpost. I'm only pointing the fact that it is possible, and saying it is impossible is false. Personally, I don't find the function-call format that "annoying", and I think it presents some advantages neither JSX nor template strings have, along with some disadvantages (it's more verbose, like you pointed out).
- goliatone 8y agoAnd I think GP was saying even if possible it seems rather irrelevant. You could use react without JSX but most likely you will not because you would be throwing away the good things about react. Technically you can eat soup using a fork, but you won’t because...
- shados 8y agoWhen React was new and compilers/tooling wasn't that good it was pretty common to use it without JSX. JSX is pervasive because the tooling is now first class (and you'll need it if you make a non-trivial app sooner or later...at which point might as well use JSX since its there), but it works perfectly find without. My first couple commercial apps for React didn't use JSX and it was quite usable. There's just a lack of examples on how to do it these days because no one bothers. The only time when you won't really have access to a tool chain is for quick demos with just an html page and a script tag (if you don't want to pull in babel as a script), but most online tool allow jsx too now anyway.
- nicoburns 8y agoThere's also a babel script that you can drop into a script tag and will transpile stuff in the browser for you if you want JSX. Not recommended for large projects in production (but then I'd be using webpack or similar for large vue projects too), but it works pretty well (and surprisingly fast) for quick experiments.
- k__ 8y agoI wrote a tutorial about this. In this lesson I cover JSX: https://github.com/kay-is/react-from-zero/blob/master/02-jsx.html https://github.com/kay-is/react-from-zero/blob/master/02-jsx...