4 ms·
> While React has paved the way, JSX syntax is not only tied to React. Does TypeScript manage the lifecycles of elements you create through their version of JS
by VeilEm 11y ago
> While React has paved the way, JSX syntax is not only tied to React.
Does TypeScript manage the lifecycles of elements you create through their version of JSX? React creates an in memory version of the DOM and reconciles changes to the DOM against this. Is TypeScript doing this too or is this simply template syntax inside JavaScript? What React does is not simply template syntax. HTML and JSX are totally different things! JSX renders to HTML eventually, but there's way more going on.
- saidajigumi 11y agoAccording to https://github.com/Microsoft/TypeScript/wiki/JSX https://github.com/Microsoft/TypeScript/wiki/JSX, there are two JSX processing options. The first is a JSX passthru ("preserve" mode) and the second ("react" mode) will generate React.createElement, etc. See that page for the technical details. As such, preserve mode is intended for use with other backends, e.g. those listed under Transpilers at https://facebook.github.io/jsx/ https://facebook.github.io/jsx/. Whichever non-React backend you choose therefore defines the JSX runtime handling rather than having that baked into TypeScript.
- orf 11y agoI think you're misunderstanding the feature, see here for more info: https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#custom-jsx-factories-using---reactnamespace https://github.com/Microsoft/TypeScript/wiki/What's-new-in-T...
- Guillaume86 11y agoYou're mixing up React and JSX. Typescript do not replace React, it just allows JSX syntax and transforms it to javascript for you if you want.
- deleted 11y ago[deleted]
- WorldMaker 11y agoAlso, Typescript type checks the JSX. This was the big thing that convinced me to start using TSX was typed views. (I've not been using React, so I've been using preserve behavior and Babel to feed the Virtual DOM library I am using.)