reactjs.net - are react-text tags required when rendered?

前端 未结 1 515
春和景丽
春和景丽 2021-01-23 05:46

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, w

相关标签:
1条回答
  • 2021-01-23 06:32

    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.

    0 讨论(0)
提交回复
热议问题