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

How is it even possible that React allows you to write JSX (XML) within javascript without it throwing

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745175474a4615167.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信