4 ms·
> "Everything an HTML tag" is an insane mantra to have. I don't think this is a React mantra at all. Maybe "everything is a function" would be a modern React m
by sunaurus 6y ago
> "Everything an HTML tag" is an insane mantra to have.
I don't think this is a React mantra at all. Maybe "everything is a function" would be a modern React mantra? Seeing how React code is mostly hooks and components, and both are nowadays generally written as functions.
JSX is not even required when writing React, by the way. It's just syntactic sugar.
> It's crazy to me that it's normal now to have like 3-4 compilation/transpilation steps when working on a simple JS-based app.
There's nothing about React that requires this. You can simply include the react.js script at the beginning of your HTML document and write all the React code you want, no transpilation required.
If you want to use JSX, then you need transpilation, but again, JSX is not required to use React.
- capableweb 6y agoYou seem to confuse "normal" with "required". dvt (correctly) states that "it's normal now to have like 3-4 compilation/transpilation" which is indeed true for most React codebases (open source and not) I've came across. In fact, I don't think I've come across a single React application that is seriously built without using JSX and without a bundler (like including react.js in the beginning of HTML). While not required, most people use JSX + bundler, at least for anything that resembles a serious application.
- TomMarius 6y agoBut what's so hard/bad? Literally zero config and two commands: npm install -g parcel-bundler parcel ./index.html
- goliatone 6y agoIt adds complexity. Software rots faster. You are more likely to git clone a 7 year old front end project and be able to run it successfully than a 7 month old project. It’s hard to find projects that successfully pin versions down so that you can build them after regular work on them has stopped.
- TomMarius 6y agoI have projects from 7 years ago that got dependencies stuck on an old major (that's the default) and the webpack I put there in 2013 still successfully builds. The original versions are noted in package.json, so all you might need to do is fix it to the minor/patch (1min task with search/replace). I wouldn't be afraid of parcel - you can do the same thing.
- capableweb 6y agoThose two commands are not just "zero config and two commands", think about the entire stack you're pulling down behind the scenes. Sure, it's easy when you want to render "hello world" but there is so much context and abstraction happening here, that is hidden. Then we haven't even started thinking about HOCs, SSR and lifecycle hooks, none of them addressed by your terminal snippet.
- TomMarius 6y agoActually everything is done after this. This is the way I am building a huge SaaS project. Of course it downloads some code, or would you argue that using Javascript is not simple because it needs to run in a browser? Server rendering is trivial to set up with Parcel, but I don't see the point of your remark - you don't have any option of server side rendering with Jquery.
- osdiab 6y agoPeople who use React tend to want to use modern browser capabilities - and anyone who does will need transpilation because browsers have different API support - the cost of not having an all-controlling monopoly. People developing on other platforms love to complain about the build tools on the web, but those same people only have the luxury of simpler build pipelines because they have greater control over the machines their code will be run on. I don’t see React as having caused this problem in any way (feel free to include React via a script tag from a CDN and worry about the compatibility of your code yourself), and I also don’t see this as a problem that will go away any time soon for web development. That all said, I do think it’s getting better - all the major browsers have switched to be auto-updating, so it’s feasible for many projects to drop support for IE altogether and only support ES6; if you manage your CSS in JS, you don’t need to downcompile languages like SCSS; the two of those together mitigates a lot of the need for sophisticated build tools.
- baddox 6y agoCouldn’t that simply be because bundlers/compilers are really nice and that’s why people choose to use them despite the fact that they’re optional?
- test1235 6y ago>JSX is not required to use React Everyone keeps repeating this, but looking at a pile of 'createElement' calls is so much harder to read than just looking at a page of html.
- ng12 6y agoAnd so you introduce a simple build step to improve your development experience.
- Zarel 6y agoThere are a lot of libraries to it more readable: https://blog.bloomca.me/2019/02/23/alternatives-to-jsx.html https://blog.bloomca.me/2019/02/23/alternatives-to-jsx.html If you don't want to use any of them, convention is to use: const h = React.createElement; I don't know of anyone who actually uses `React.createElement` directly. Personally, with all the other things needing a transpile step (TypeScript, and support for older browsers), I've just gotten used to having one in every project nowadays.