最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How does Facebook's React JSX transformer work? - Stack Overflow

programmeradmin0浏览0评论

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 badges
Add a ment  | 

1 Answer 1

Reset to default 10

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.

发布评论

评论列表(0)

  1. 暂无评论