Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save j0lvera/f86d215ac831beda49b5 to your computer and use it in GitHub Desktop.
Save j0lvera/f86d215ac831beda49b5 to your computer and use it in GitHub Desktop.
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.props.onSavePrice(this.props.price)}>
<img className="app-icon" src={this.props.icon} width="125px" />
<p className="app-option-name">{this.props.name}</p>
</li>
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment