3 ms·
React is not a templater, it's a differ. The only similarity between PHP and React is that you can have tags in ("around" in PHP's case) your code. Edit: After
by iotscale 10y ago
React is not a templater, it's a differ. The only similarity between PHP and React is that you can have tags in ("around" in PHP's case) your code.
Edit: After reading my comment again, I feel I must mention; even that similarity is not coming from React directly. It's JSX. Although they go like fish & chips together (Not a great analogy but I guess I'm hungry).
- vladimir-y 10y ago> React is not a templater, it's a differ. It's a templater, read my message above - an advanced tempalter, which means it has some DOM rendering optimizations. > The only similarity between PHP and React is that you can have tags in ("around" in PHP's case) your code. Not just tags, but an entire "view" thing, a representation, so old fashion messy/sloppy/spaghetti-like PHP like code style.
- iotscale 10y agoYou give React a state, it diffs that and passes the outcome to the ReactDOM, which can render it on the DOM. At its core React doesn't know what a <div/> is. It just diffs objects and generates instructions to reach the next state (very generally speaking here). The stuff you pass to it is an object and can't be malformed like a string can. Main function of React is maybe loosely related with templating. For PHP (in its traditional form), everything around the code is just strings, which is also the case for most of the templating engines. You can't shout "spaghetti code" every time you see XML tags in code. Think Scala or VB.
- catshirt 10y agonothing about React is messy or sloppy. it is the exact opposite. the notion that your view logic and it's template must be completely decoupled is an antiquated and misguided best practice.