3 ms·
In his example in the pre-preface there was quite a big amount of logic.. I don't really see the point in your post looking at that code.
by tigershark 10y ago
In his example in the pre-preface there was quite a big amount of logic..
I don't really see the point in your post looking at that code.
- haukur 10y agoYou can have complex logic and functions in JSX but that doesn't mean that you have to, so the example is very contrived. That way of writing the code is completely discouraged in the documentation and I haven't run across it often or at all in the real world.
- autoreleasepool 10y agoThe example in the article was lifted from the front page of the official React website [0]. [0] https://facebook.github.io/react/ https://facebook.github.io/react/
- haukur 10y agoIt wasn't lifted from the docs. The tutorial is a tic-tac-toe game, while the example in the post is an AddTodo function [edit: there appears to be an add todo section, but the code is completely different]. Furthermore, all the examples in the tutorials show a pattern where you reference functions instead of writing them inside JSX.
- autoreleasepool 10y agoCheck again. On the homepage scroll down to: > An Application " Using props and state, we can put together a small Todo application. This example uses state to track the current list of items as well as the text that the user has entered. Although event handlers appear to be rendered inline, they will be collected and implemented using event delegation. "
- haukur 10y agoFair enough - it's a todo app. The code isn't structured in the same manner as the author's, however, so my point stands. It doesn't look like the code was lifted from the docs, as you said, but instead transformed to look like spaghetti.
- inopinatus 10y agoI thought that was irony, nuanced by a sly dig at Facebook. The gist being that React is what happens when a PHP shop creates a client-side framework, with all the architectural warts that this might imply, if you're on the PHP-lowers-the-bar-to-web-programming-too-far bandwagon. (FB engineers would probably tell you that their variant, Hack, is a far cry from PHP, and their coding standards are well above that of your bargain-basement wordpress drudge, but you get the idea)
- bryanlarsen 10y agoThe third paragraph was one that said that good PHP looks like React and bad React looks like PHP, but I deleted it because I thought it was stronger letting the reader make their own inference.