1.把元素渲染进DOM@H_301_1@
To render a React element into a root DOM node,pass both to
ReactDOM.render()
为了把一个react元素渲染进DOM,把他们两个都传进ReactDOM.render()方法。
const element = <h1>Hello,world</h1>;
ReactDOM.render(
element,document.getElementById('root')
);
2.更新渲染的元素@H_301_1@
React elements areimmutable. Once you create an element,you can't change its children or attributes. An element is like a single frame in a movie: it represents the UI at a certain point in time.
React元素是不可变的。一旦你创建一个元素,你不能改变他的Children或者属性。
With our knowledge so far,the only way to update the UI is to create a new element,and pass it toReactDOM.render()
.
到目前我们所学到的唯一的方法去更新UI就是去创建一个新的元素,然后传进render()方法。
3.React只会更新需要更新的部分@H_301_1@
原文链接:https://www.f2er.com/react/304476.html
To render a React element into a root DOM node,pass both toReactDOM.render()
为了把一个react元素渲染进DOM,把他们两个都传进ReactDOM.render()方法。
const element = <h1>Hello,world</h1>; ReactDOM.render( element,document.getElementById('root') );
2.更新渲染的元素@H_301_1@
React elements areimmutable. Once you create an element,you can't change its children or attributes. An element is like a single frame in a movie: it represents the UI at a certain point in time.
React元素是不可变的。一旦你创建一个元素,你不能改变他的Children或者属性。
With our knowledge so far,the only way to update the UI is to create a new element,and pass it to
ReactDOM.render()
.到目前我们所学到的唯一的方法去更新UI就是去创建一个新的元素,然后传进render()方法。