reactjs.net - are react-text tags required when re

2019-03-01 04:58发布

I have been following this tutorial http://reactjs.net/getting-started/tutorial.html and all works great. However in the final output source, I get the following comment tags, why is the text wrapped around the react-text tags, are they required tags? Why are they in comment tags? Can they be removed somehow?

<!-- react-text: 6 -->Hello ReactJS.NET World!<!-- /react-text -->
<!-- react-text: 9 -->This is one comment<!-- /react-text -->

标签: reactjs.net
1条回答
再贱就再见
2楼-- · 2019-03-01 05:51

The comments are needed, they're used internally by React to denote segments of text. For example, if you render two variables directly next to each other, React uses the comments to know where one variable ends and the next variable begins, so it can correctly update the text on updates.

This was changed in React v15, previous versions used <span>s to wrap the text segments. There's more information at https://facebook.github.io/react/blog/2016/04/07/react-v15.html#no-more-extra-ltspangts.

查看更多
登录 后发表回答