Reputation: 283
How is it even possible that React allows you to write JSX (XML) within javascript without it throwing any errors? I have been trying to wrap my head around it, and I am not quite sure how the underlying code accomplishes this.
Upvotes: 12
Views: 1005
Reputation: 32786
Simple, it looks for <script type="text/jsx">
tags, parses them, generates the corresponding javascript code, and eval
's it.
This is why the jsx
inline transformer should be used only when developing, as having to parse the jsx
code decreases the performance of your web page. When deploying, you should convert all jsx
code into js
one before deploy.
Upvotes: 10