mirror of
https://github.com/Raghu-Ch/ReactWeather.git
synced 2026-02-10 03:03:01 -05:00
27 lines
587 B
JavaScript
27 lines
587 B
JavaScript
var React = require('react');
|
|
|
|
var WeatherForm = React.createClass({
|
|
onFormSubmit: function (e) {
|
|
e.preventDefault();
|
|
|
|
var location = this.refs.location.value;
|
|
|
|
if (location.length > 0) {
|
|
this.refs.location.value = '';
|
|
this.props.onSearch(location);
|
|
}
|
|
},
|
|
render: function () {
|
|
return (
|
|
<div>
|
|
<form onSubmit={this.onFormSubmit}>
|
|
<input type="text" ref="location"/>
|
|
<button className="button expanded hollow">Get Weather</button>
|
|
</form>
|
|
</div>
|
|
);
|
|
}
|
|
});
|
|
|
|
module.exports = WeatherForm;
|