3 ms·
You 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 comple
by haukur 9y ago
You 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 9y 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 9y 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 9y 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 9y 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.