Closed
Description
/template/src/App.js
is now using React Component Class, but this component is stateless.
So I think <App />
should be Stateless Functional Component.
I'm not good at English, here is a code example of my idea.
ASIS:
class App extends Component {
render() {
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Welcome to React</h2>
</div>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
</div>
);
}
}
TOBE:
const App = () => (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Welcome to React</h2>
</div>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
</div>
);
If you agree this proposal, I will create a pull request!
Activity
gaearon commentedon Jul 31, 2016
Hi, we think most beginners would be confused seeing SFC there because we still don't use them as much in the documentation. Additionally they would not be sure how to add state or lifecycle methods. Moreover we would miss an opportunity to show that this project supports ES classes out of the box, so they would probably use createClass() syntax. Combined, these are the reasons we don't use SFC in this example.