Skip to content

Commit

Permalink
Fixed Warning: 'Using <Image> with children is deprecated'
Browse files Browse the repository at this point in the history
  • Loading branch information
i6mi6 committed Oct 9, 2017
1 parent ed72401 commit 1614fd6
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 1614fd6

Please sign in to comment.