Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What makes me upset about JSX is how it's build-time-dependent on whichever specific library you've configured it to translate to (and can't be used otherwise)

Imagine if JSX produced a standard data structure that could then be

- Rendered by React or another framework

- Serialized to a string

- Deeply inspected/compared

etc. And framework integration only happened when you make the actual framework call, not globally at build-time



It certainly could be done for many use cases, it would probably be ~a superset of the various transformers’ ASTs. But that could add a fair bit of overhead to runtimes, particularly for transforms which deviate significantly from React’s tree structure (eg Solid’s underlying dom-expressions).


You can write custom jsx function and let typescript call your function instead of react's.

Your custom jsx function can return data in reusable format, that is passed to different functions for difference use case.

ts-liveview is using this approach to use jsx for both server-side rendering and compact over-the-wire updates


What I'd like is for it to have been a standard language feature, that can be used with or without a framework and without any build involvement




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: