Reputation: 122
please solve this problem . it had been 4 days of of this error and the developer can understand its pain. i also log in the console but it was fine . but in render it is not working.
constructor(props){
super(props);
this.state = {
term: '',
imgLink: '',
};
};
fetchData = data => {
var foo = data.items[0].snippet.thumbnails.default.url;
this.setState({imgLink: foo});
}
render (){
return(
<Image
style={{
width:width,
height:70,
alignItems:'center',
borderRadius:50,
marginLeft:'auto',
marginRight: 'auto',
marginTop: 100
}}
source={this.props.url ? { uri: this.props.imgLink } : null}/>
);
}
Upvotes: 0
Views: 1771
Reputation: 31
You have used props instead of state in url access. As you can see you declared variable imgLink in state not as props.
this.state = { term: '', imgLink: '', };
Solution: source={this.state.imgLink ? { uri: this.state.imgLink } : null}/>
use above instead of props.
Upvotes: 1