Last active
August 29, 2015 14:02
-
-
Save Daniel15/5c5b4407305b505acde7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Options = React.createClass({ | |
savePrice: function(price) { | |
localStorage.setItem("Price", price); | |
}, | |
_renderOptions: function() { | |
return this.props.data.map(function(option) { | |
return ( | |
<Option | |
price={option.price} | |
icon={option.icon} | |
name={option.name} | |
onSavePrice={this.savePrice} | |
/> | |
) | |
}, this); | |
}, | |
render: function() { | |
return ( | |
<ul className="app-options"> | |
{this._renderOptions()} | |
</ul> | |
); | |
} | |
}); | |
var Option = React.createClass({ | |
render: function() { | |
<li className="app-option" onClick={this._onClick}> | |
<img className="app-icon" src={this.props.icon} width="125px" /> | |
<p className="app-option-name">{this.props.name}</p> | |
</li> | |
}, | |
_onClick: function() { | |
this.props.onSavePrice(this.props.price); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment