Skip to content

Instantly share code, notes, and snippets.

@Daniel15
Last active August 29, 2015 14:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Daniel15/5c5b4407305b505acde7 to your computer and use it in GitHub Desktop.
Save Daniel15/5c5b4407305b505acde7 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._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