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 acplishes this.
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 acplishes this.
Share Improve this question edited Jan 30, 2016 at 10:24 Dmitry Shvedov 3,3164 gold badges40 silver badges56 bronze badges asked May 14, 2015 at 19:52 SMLMRKHLMSSMLMRKHLMS 2832 silver badges6 bronze badges1 Answer
Reset to default 10Simple, 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.