Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.