I'm new to React and trying to get a handle on syntax.
I'm developing in a React 15 environment (using the react-starterify template) and have been using the syntax in VERSION 2 below, but, most of the examples and tutorials I find in Facebook's React pages are VERSION 1. What's the difference between the two and when should I use the one over the other?
VERSION 1
var MyComponent = React.createClass({
render: function() {
return (
<ul>
// some list
</ul>
);
}
});
module.exports = MyOtherComponent;
VERSION 2
const MyComponent = () => (
<ul>
// some list
</ul>
);
export default MyComponent;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…