My goal is to check an image source url to check whether it is valid or not. If it is valid, display the React Native Image as normal and if not, replace it with a local placeholder image. However, the following typescript function never seems to return anything and nothing is displayed.
renderImage(): JSX.Element { fetch(this.props.imageUrl) .then(res => { if(res.status == 404) { return (<Image source={require('../images/nasa-logo.png')} style={styles.imageThumbnail} /> ) } else { return (<Image source={{uri: this.props.imageUrl}} style={styles.imageThumbnail} /> ) } }) .catch(err => { return (<Image source={require('../images/nasa-logo.png')} style={styles.imageThumbnail} /> ) }) return null // <-- skips to here }