Live data from Hacker News

Things every React.js beginner should know

camjackson.net

111–120 of 247 posts

Re: Things every React.js beginner should know

#111
post #99
post #55

Earlier quoted context omitted.

In all fairness this is ancient history on the PHP world.

> In all fairness this is ancient history on the PHP world. No, because PHP still work that way (hypertext pre-processor) and Yes because, PHP has frameworks that makes PHP work like other solutions (Ruby,Python,Java + frameworks), but one still need a And again, a lot of PHP developers despise these frameworks and question their usefulness. In theory, they are right since PHP is a template language which goal is to…

I have no idea how starting with <?php in a file is relevant. Should we also start mocking languages that expect a given file extension?

Re: Things every React.js beginner should know

#112

Someone sell me on Webpack? We use Browserify for no other reason than that someone gave me a boilerplate Gulpfile that relied on it. What part of my life would actually get better if I took the 4 hours of my life I will never get back to make this switch? Thanks!

Here's their comparison with browserify and others: https://webpack.github.io/docs/comparison.html. Personally, I use browserify because it is ultra simple to get set up. No config file, gulpfile or anything and I'm using es6 and watchify to auto recompile. We use webpack at work, it's more performant and has some nice features, like using it manage your css and images as well, but getting it set up can be a headache.

Re: Things every React.js beginner should know

#113

Someone sell me on Webpack? We use Browserify for no other reason than that someone gave me a boilerplate Gulpfile that relied on it. What part of my life would actually get better if I took the 4 hours of my life I will never get back to make this switch? Thanks!

I think Webpack has the monolith advantage here. It allows you to add things that would otherwise be immensely complex with ease because it can do a lot. You can have it handle bundle splitting and async loading of modules, image optimising and hashing, CSS/SASS/... processing, ... Since we started using Webpack where I work we've stopped using all other build tools. There's very little Webpack can't do, and the main…

So a big reason to use Webpack is that I can replace both Gulp and Browserify with it, and have one fewer component?

Re: Things every React.js beginner should know

#114
post #78

What really bothers me about React (and other frameworks) that without JS you do not see anything. No fallback. No progressive enhancement. Is this really the way to go? Did JS replace HTML/CSS as the backbone of websites/applications ?

And without JS you don't get real applications on the web. Dumb text is fine for web 1.0, 2.0, but modern web applications are expanding far beyond that. Are there ways to be abusive with JS? Sure. But JS is what enables web applications as opposed to just having text-on-page (newspaper 2.0).

Re: Things every React.js beginner should know

#115
post #91

Earlier quoted context omitted.

> ... that then expand to be turing-complete and basically offer everything their primary language offered in the beginning. then they wrote template languages on top of the template language to separate layout and logic again ( PHP vs Twig/Smarty ) so maybe we need to step back a little and figure out how to write a language that wouldn't need a different syntax for logic and layout. This family of languages exists…

I'm a huge fan of Clojure's Hiccup library. It allows the user to make html like the following. Here's a function that always returns true - but it could do any kind of data access. It is just plain Clojure. (defn selected? [] true) Here is a datastructure that represents html: [:h2 {:class (when (selected?) "selected")} "Hello"] Calling the function hiccup.core/html on that datastructure yeilds an html string like t…

I don't know man. Every time I've worked with that style of approaching the problem, it feels like I'm just writing HTML with different syntax.

Re: Things every React.js beginner should know

#116
post #78

What really bothers me about React (and other frameworks) that without JS you do not see anything. No fallback. No progressive enhancement. Is this really the way to go? Did JS replace HTML/CSS as the backbone of websites/applications ?

Honestly, it's 2016. Running a modern web page and browser without javascript is just silly. You're losing out on a lot of quality of life features, that people just expect to be there. It's the equivalent of taking away a touch interface from modern mobile phones.

Re: Things every React.js beginner should know

#118

Someone sell me on Webpack? We use Browserify for no other reason than that someone gave me a boilerplate Gulpfile that relied on it. What part of my life would actually get better if I took the 4 hours of my life I will never get back to make this switch? Thanks!

You can run "webpack-dev-server", which uses your Webpack configuration to serve your scripts with its own web server.

That means (1) it can do incremental recompilation, which I can't live without since my build takes 20 seconds; and (2) it can block requests while compiling, which is way better than having a background thing (e.g. watchify) recompile your code, since it means you're never interacting with a stale (or god forbid partial) compile.

The dev server also does automatic page reloading on recompile via some injected script magic. In my case that means I often don't even need to alt-tab to see my updates, like if I'm messing around with styling.

Webpack also has a whole paradigm that expands the use cases of require() in a pretty interesting and useful way. For example, you can tell it that require("../../icons/lolcat.png") should resolve to "static/lolcat.[8 chars of base64 SHA-256].png" and also do the appropriate file copying. Or you might want require("./stuff.csv") to resolve to a parsed JSON table, or any such transformation. There are a bunch of plugins for common uses. It's common to use require() even to load your CSS, because then Webpack can handle running it through your auto-prefixer or whatever.

It might seem kind of bloated, and I love Browserify for its simplicity, but I've come around to really like Webpack now that I've spent the proverbial 4 hours.

Re: Things every React.js beginner should know

#119
post #91

Earlier quoted context omitted.

This is a debate that has been going on since I started in the late 90ies. You need some sort of logic in your views, no matter what system you use, i. e. loops or formatting dates. Because people are raised on the "don't mix logic & layout" maxim, they feel dirty when they write sich logic in their usual language. .. so they invent template languages... ... that then expand to be turing-complete and basically offer…

> ... that then expand to be turing-complete and basically offer everything their primary language offered in the beginning. then they wrote template languages on top of the template language to separate layout and logic again ( PHP vs Twig/Smarty ) so maybe we need to step back a little and figure out how to write a language that wouldn't need a different syntax for logic and layout. This family of languages exists…

If you are trying to make a language that doesn't need a different syntax for logic and layout, do you not end up with a templating language similar to PHP? Is this the right goal?

Re: Things every React.js beginner should know

#120
post #27
post #9

> 5. Use Redux.js Well, that is not really something every React.js beginner should know. Feels weird to say that a X beginner should learn framework Y since he is probably just interested in X... > 6. Always use propTypes Worth mentioning that this slows down your application since React needs to check all the props. Don't forget to set NODE_ENV=production when compiling your production script.

If you are learning MVC, only learning V is not going to get you far. I do wonder if things like Typescript can solve a lot of the speed issues.

Well, if you set out to learn React (which this article is about), you are only learning React. Not even V in MVC because probably you're not out after learning MVC. You're out after learning React.
Post reply on HN