Reputation: 390
I can shot photo picture, print on the screen and successfully upload on the server. But just after re-visiting profile page default picture doesn't shown
<TouchableOpacity onPress={this.shotPhoto.bind(this)}>
<Image style={{ height: 200, width: 150 }} source={{ uri: this.props.userpicture } == { uri: 'http://webstudio.web.tr/resimler/resimyok.png' } ? { uri: 'http://webstudio.web.tr/resimler/kullaniciresmi/' + this.state.email + '.jpeg' } : { uri: this.props.userpicture }} />
<Text style={{ height: 50, width: 150, backgroundColor: 'green' }}>Shot a photo</Text>
</TouchableOpacity>
The complate source code of my project is at https://github.com/EnginYilmaz/kpbduser/blob/master/src/user/HesabimForm.js
(Yes, it is important for me to give me any idea)
Upvotes: 1
Views: 245
Reputation: 390
I find a workaround my solution is:
isShotPhoto () {
if (!this.props.userpicture ) {
return (
<TouchableOpacity onPress={this.shotPhoto.bind(this)}>
<Image style={{ height: 200, width: 150 }} source={{ uri:'http://webstudio.web.tr/resimler/kullaniciresmi/'+this.state.email+'.jpeg' }} />
<Text style={{ height: 50, width: 150, backgroundColor: 'green' }}>Fotoğrafınızı çekin</Text>
</TouchableOpacity>
);
} else {
return (
<TouchableOpacity onPress={this.shotPhoto.bind(this)}>
<Image style={{ height: 200, width: 150 }} source={{ uri:this.props.userpicture }} />
<Text style={{ height: 50, width: 150, backgroundColor: 'green' }}>Fotoğrafınızı çekin</Text>
</TouchableOpacity>
);
}
}
Upvotes: 0
Reputation: 4255
I'm not sure of exact problems but here you compare object with another object which will always be false regardless of userpicture
value:
{ uri: this.props.userpicture } == { uri: 'http://webstudio.web.tr/resimler/resimyok.png' } ? { uri: 'http://webstudio.web.tr/resimler/kullaniciresmi/' + this.state.email + '.jpeg' } : { uri: this.props.userpicture }
Try to compare URLs instead:
this.props.userpicture == 'http://webstudio.web.tr/resimler/resimyok.png' ? { uri: 'http://webstudio.web.tr/resimler/kullaniciresmi/' + this.state.email + '.jpeg' } : { uri: this.props.userpicture }
Upvotes: 1