Skip to content

Commit

Permalink
Merge pull request #61 from i6mi6/master
Browse files Browse the repository at this point in the history
Fixed Warning: 'Using <Image> with children is deprecated'
  • Loading branch information
jeanpan authored Oct 15, 2017
2 parents ed72401 + 1614fd6 commit d67038d
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions ImageItem.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {Component} from 'react';
import React, { Component } from 'react';
import {
Image,
StyleSheet,
Expand All @@ -8,40 +8,39 @@ import {
import PropTypes from 'prop-types';

class ImageItem extends Component {
constructor(props){
constructor(props) {
super(props)
}

componentWillMount() {
var {width} = Dimensions.get('window');
var {imageMargin, imagesPerRow, containerWidth} = this.props;
var { width } = Dimensions.get('window');
var { imageMargin, imagesPerRow, containerWidth } = this.props;

if(typeof containerWidth != "undefined") {
if (typeof containerWidth != "undefined") {
width = containerWidth;
}
this._imageSize = (width - (imagesPerRow + 1) * imageMargin) / imagesPerRow;
}

render() {
var {item, selected, selectedMarker, imageMargin} = this.props;
var { item, selected, selectedMarker, imageMargin } = this.props;

var marker = selectedMarker ? selectedMarker :
<Image
style={[styles.marker, {width: 25, height: 25}]}
source={require('./circle-check.png')}
/>;
<Image
style={[styles.marker, { width: 25, height: 25 }]}
source={require('./circle-check.png')}
/>;

var image = item.node.image;

return (
<TouchableOpacity
style={{marginBottom: imageMargin, marginRight: imageMargin}}
style={{ marginBottom: imageMargin, marginRight: imageMargin }}
onPress={() => this._handleClick(image)}>
<Image
source={{uri: image.uri}}
style={{height: this._imageSize, width: this._imageSize}} >
{ (selected) ? marker : null }
</Image>
source={{ uri: image.uri }}
style={{ height: this._imageSize, width: this._imageSize }} />
{(selected) ? marker : null}
</TouchableOpacity>
);
}
Expand Down

0 comments on commit d67038d

Please sign in to comment.