我已經能夠以幾種不同的方式呈現React中的組件,但是,我不確定這樣呈現之間的實際區別是什麼:通過導入和導入+ ReactRender.DOM呈現之間的區別 - React
App.js(樣品切):
import Cartesian from './cartesian'
//Somewhere inside the App.js component:
<div id="graph">
<Cartesian/>
</div>
Cartesian.js:
export default class Cartesian extends Component {
render() {
return <h1> Ex </h1>
}
}
現在這個完美的作品,不過,我不知道的區別,如果我有添加的東西臨客ŧ他:
import Cartesian from './cartesian'
//Somewhere inside the App.js component:
<div id="graph">
<Cartesian/>
</div>
ReactDOM.render(<Cartesian/>,document.getElementById("graph"));
甚至這樣的:
import Cartesian from './cartesian'
//Somewhere inside the App.js component:
<div id="graph">
</div>
ReactDOM.render(<Cartesian/>,document.getElementById("graph"));
渲染明智的,做任何這些有什麼區別?我已經從API和這篇有用的文章(React vs ReactDOM?)閱讀了一些關於React DOM的內容。然而,在渲染方面,這個主題對我來說並不是很清楚。
在此先感謝。