react笔记

注意事项:

1 Note that native HTML element names start with a lowercase letter, while custom React class names begin with an uppercase letter.

1 请注意原生HTML元素的名字以小写字母开头,而自定义的React类名字以大写字母开头;
特别注意:不管是原生HTML还是自定义React类其最高层元素(本例中comment-box类)不能出现兄弟及元素,且文本内容不得出现:<,即使输入& l t也无法显示小于号。这点真让人不爽!;
 
例如:React自定义类
var CommentBox=React.createClass({
  render:function(){
return (
 
hello world i am a comment box!
 
);
}
 });
ReactDOM.render(,$('#content')[0]);
 
原生HTML
var commentBox=
 
  hello world i am a comment box!
;
ReactDOM.render(commentBox,$('#content')[0]);

疑问:

Notice how we're mixing HTML tags and components we've built. HTML components are regular React components, just like the ones you define, with one difference. The JSX compiler will automatically rewrite HTML tags to React.createElement(tagName)expressions and leave everything else alone. This is to prevent the pollution of the global namespace.(哪来的全局变量?)

posted @ 2016-06-16 18:21  哈哈!最初的梦想  阅读(124)  评论(0)    收藏  举报