Skip to content

Commit

Permalink
fix: Remove unncessary image load check
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-coldwell committed Jan 17, 2023
1 parent c262265 commit 0a17bfa
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/components/ImageWithSizeCalculation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, {PureComponent} from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import lodashGet from 'lodash/get';
import Log from '../libs/Log';
import styles from '../styles/styles';
import FullscreenLoadingIndicator from './FullscreenLoadingIndicator';
Expand Down Expand Up @@ -45,7 +44,7 @@ class ImageWithSizeCalculation extends PureComponent {
this.imageLoadingStart = this.imageLoadingStart.bind(this);
this.imageLoadingEnd = this.imageLoadingEnd.bind(this);
this.onError = this.onError.bind(this);
this.imageLoadedSuccessfuly = this.imageLoadedSuccessfuly.bind(this);
this.imageLoadedSuccessfully = this.imageLoadedSuccessfully.bind(this);
}

onError() {
Expand All @@ -60,13 +59,11 @@ class ImageWithSizeCalculation extends PureComponent {
this.setState({isLoading: false});
}

imageLoadedSuccessfuly(event) {
if (!lodashGet(event, 'nativeEvent.width', false) || !lodashGet(event, 'nativeEvent.height', false)) {
// Image didn't load properly
return;
}

this.props.onMeasure({width: event.nativeEvent.width, height: event.nativeEvent.height});
imageLoadedSuccessfully(event) {
this.props.onMeasure({
width: event.nativeEvent.width,
height: event.nativeEvent.height,
});
}

render() {
Expand All @@ -89,7 +86,7 @@ class ImageWithSizeCalculation extends PureComponent {
onLoadStart={this.imageLoadingStart}
onLoadEnd={this.imageLoadingEnd}
onError={this.onError}
onLoad={this.imageLoadedSuccessfuly}
onLoad={this.imageLoadedSuccessfully}
/>
{this.state.isLoading && (
<FullscreenLoadingIndicator
Expand Down

0 comments on commit 0a17bfa

Please sign in to comment.