9 ms·
Also keep in mind that javascript engines have a built-in mechanism for including multi-line strings with a powerful substitution engine: tagged template string
by substack 10y ago
Also keep in mind that javascript engines have a built-in mechanism for including multi-line strings with a powerful substitution engine: tagged template strings (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...). The upside of template strings is that you can run your code directly in node or electron without using extra tooling first. It is possible and not hard to use tagged templates with react, although few people do. It's more common in some other frontend ecosystems.
- pitaj 10y agoJSX isn't templating. It's representing a virtual dom tree of function calls with a syntax more representative of the resulting markup.
- substack 10y agoYou can build virtual dom trees or use real dom nodes using something like https://www.npmjs.com/package/morphdom https://www.npmjs.com/package/morphdom . Tagged template strings let you build these features in without custom language extensions. See also: * https://www.npmjs.com/package/hyperx https://www.npmjs.com/package/hyperx * https://www.npmjs.com/package/yo-yo https://www.npmjs.com/package/yo-yo
- pitaj 10y agoRight, but these just do what JSX does, but in runtime instead of at compile time.