diff --git a/app/components/About.jsx b/app/components/About.jsx index e714dea..66d9a86 100644 --- a/app/components/About.jsx +++ b/app/components/About.jsx @@ -1,11 +1,17 @@ var React = require('react'); -var About = React.createClass({ - render: function (){ - return ( -

About Component

- ); - } -}); +// var About = React.createClass({ +// render: function (){ +// return ( +//

About Component

+// ); +// } +// }); + +var About = (props) => { + return ( +

About Component

+ ); +}; module.exports = About; diff --git a/app/components/Examples.jsx b/app/components/Examples.jsx index 9e80c09..acb697b 100644 --- a/app/components/Examples.jsx +++ b/app/components/Examples.jsx @@ -1,11 +1,16 @@ var React = require('react'); -var Examples = React.createClass({ - render: function () { - return ( -

Examples Component

- ); - } -}); +// var Examples = React.createClass({ +// render: function () { +// return ( +//

Examples Component

+// ); +// } +// }); +var Examples = () => { + return ( +

Examples Component

+ ); +}; module.exports = Examples; diff --git a/app/components/Main.jsx b/app/components/Main.jsx index f09d630..63350ca 100644 --- a/app/components/Main.jsx +++ b/app/components/Main.jsx @@ -1,17 +1,28 @@ var React = require('react'); var Nav = require('Nav'); -var Main = React.createClass({ - render: function () { - return ( -
-
+// var Main = React.createClass({ +// render: function () { +// return ( +//
+//
+// +// ); +// } +// }); - ); - } -}); +var Main = (props) => { + return ( +
+
+ + ); +}; module.exports = Main; diff --git a/app/components/Nav.jsx b/app/components/Nav.jsx index 84c9be7..1bff690 100644 --- a/app/components/Nav.jsx +++ b/app/components/Nav.jsx @@ -1,17 +1,27 @@ var React = require('react'); var {Link, IndexLink} = require('react-router'); -var Nav = React.createClass({ - render: function (){ - return ( -
-

Nav Component

- Get Weather - About - Examples -
- ); - } -}); +// var Nav = React.createClass({ +// render: function (){ +// return ( +//
+//

Nav Component

+// Get Weather +// About +// Examples +//
+// ); +// } +// }); +var Nav = () => { + return ( +
+

Nav Component

+ Get Weather + About + Examples +
+ ); +}; module.exports = Nav; diff --git a/app/components/Weather.jsx b/app/components/Weather.jsx index fcf383d..909b321 100644 --- a/app/components/Weather.jsx +++ b/app/components/Weather.jsx @@ -11,7 +11,7 @@ var Weather = React.createClass({ }, handleSearch: function (location) { var that = this; - + this.setState({isLoading: true}); openWeatherMap.getTemp(location).then(function (temp) { diff --git a/app/components/WeatherMessage.jsx b/app/components/WeatherMessage.jsx index e7f09a7..b6f74b6 100644 --- a/app/components/WeatherMessage.jsx +++ b/app/components/WeatherMessage.jsx @@ -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 ( +//

It's it {temp} in {location}.

+// ) +// } +// }); - return ( -

It's it {temp} in {location}.

- ) - } -}); +// Refactoring stateless function + +// var WeatherMessage = (props) => { +// var {temp, location} = props; +// return ( +//

It's it {temp} in {location}.

+// ) +// }; +// (or) +var WeatherMessage = ({temp, location}) => { + return ( +

It's it {temp} in {location}.

+ ) +}; module.exports = WeatherMessage; diff --git a/example-arrow-functions.js b/example-arrow-functions.js new file mode 100644 index 0000000..5abe3c8 --- /dev/null +++ b/example-arrow-functions.js @@ -0,0 +1,33 @@ +/** + * @file + * Provides example arrow-function functionality. + */ + +// var names = ['Swapna', 'Raghu', 'Ram']; + +// names.forEach(function (name) { +// console.log('forEach', name); +// }); + +// names.forEach((name) => { +// console.log('arrowFunc', name); +// }); + +// names.forEach((name) => console.log(name)); + +//anonymous function +function add (a,b) { + return a+b ; +} + +console.log(add(1,3)); + +//Arrow function: addStatement {for multiple lines} +var addStatement = (a,b) => { + return a + b; +} +console.log(addStatement(5,6)); + +//Arrow function: addExpression {for single line / expression } +var addExpression = (a,b) => a + b ; +console.log(addExpression(5,-3)); \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index 8926255..e4f4650 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -29,5 +29,6 @@ module.exports = { exclude: /(node_modules|bower_components)/ } ] - } + }, + devtool: 'cheap-module-eval-source-map' };