我正在关注一个反应教程,这是作者为创建一个基本的React组件而给出的示例代码:
const React = require('react')
const ReactDOM = require('react-dom')
const App = () => {
return (
<div className='app-container'>
<h1>Hello</h1>
</div>
)
}
ReactDOM.render(<App />, document.getElementById('app'))
Run Code Online (Sandbox Code Playgroud)
他声称这是ES6.
但后来我看到了另一种创建组件的方法.
class App extends React.Component {
render(){
return <h1>Hello</h1>;
}
}
Run Code Online (Sandbox Code Playgroud)
嗯,我现在很困惑.有没有标准的做法做出反应?