Refactoring: Stateless functional components

This commit is contained in:
2017-01-15 01:39:19 -08:00
parent 5926538f35
commit 01d5f986b1
8 changed files with 128 additions and 47 deletions

View File

@@ -1,13 +1,28 @@
var React = require('react');
var WeatherMessage = React.createClass({
render: function () {
var {temp, location} = this.props;
// var WeatherMessage = React.createClass({
// render: function () {
// var {temp, location} = this.props;
//
// return (
// <h3>It's it {temp} in {location}.</h3>
// )
// }
// });
return (
<h3>It's it {temp} in {location}.</h3>
)
}
});
// Refactoring stateless function
// var WeatherMessage = (props) => {
// var {temp, location} = props;
// return (
// <h3>It's it {temp} in {location}.</h3>
// )
// };
// (or)
var WeatherMessage = ({temp, location}) => {
return (
<h3>It's it {temp} in {location}.</h3>
)
};
module.exports = WeatherMessage;