Skip to content

Instantly share code, notes, and snippets.

@paramaggarwal
Created February 4, 2015 05:37
Show Gist options
  • Save paramaggarwal/898597bf634f164f55b2 to your computer and use it in GitHub Desktop.
Save paramaggarwal/898597bf634f164f55b2 to your computer and use it in GitHub Desktop.
React Native clone's example JS file for rows in the search results.
/** @jsx Rubber.createElement */
var Rubber = require('./rubber');
var TableRowItem = Rubber.createClass({
getInitialState: function() {
return {
name: '',
key: null,
didSelectRow: null
}
},
onClick: function () {
this.didSelectRow && this.didSelectRow(this.state.key);
},
render: function(props) {
var product = props.product;
var key = props.key;
this.state.name = props.product.product;
this.state.key = props.key;
this.didSelectRow = props.didSelectRow;
return (
<View style={{height: 100, flexDirection: 'row'}} onClick={this.onClick} needsClickHandler={true} >
<Image style={{
flex: 1
}}
src={product.search_image} />
<View style={{
flex: 3
}}>
<Text style={{
flex: 2,
color: '#333333'
}}
value={product.product} />
<Text style={{
flex: 1,
color: '#666666'
}}
value={product.discounted_price ? 'Rs. ' + product.discounted_price : ''} />
</View>
</View>
);
}
});
module.exports = TableRowItem;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment