Skip to content

Commit

Permalink
Fix onLoad and onError on iOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanVann committed Apr 18, 2017
1 parent a891bcf commit e98bacc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion FastImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const FastImageSourcePropType = PropTypes.shape({
FastImage.propTypes = {
...View.propTypes,
source: FastImageSourcePropType,
onFastImageError: PropTypes.func,
onFastImageLoad: PropTypes.func,
}

FastImage.defaultProps = {
Expand All @@ -53,7 +55,7 @@ FastImage.defaultProps = {
}

const FastImageView = requireNativeComponent('FastImageView', FastImage, {
nativeOnly: { onError: true, onLoad: true },
nativeOnly: { onFastImageError: true, onFastImageLoad: true },
})

export default FastImage
4 changes: 2 additions & 2 deletions ios/FastImage/FFFastImageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

@interface FFFastImageView : UIImageView

@property(nonatomic, copy) RCTDirectEventBlock onError;
@property(nonatomic, copy) RCTDirectEventBlock onLoad;
@property(nonatomic, copy) RCTDirectEventBlock onFastImageError;
@property(nonatomic, copy) RCTDirectEventBlock onFastImageLoad;
@property(nonatomic, assign) RCTResizeMode resizeMode;
@property(nonatomic, strong) FFFastImageSource *source;

Expand Down
8 changes: 4 additions & 4 deletions ios/FastImage/FFFastImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ - (void)setSource:(FFFastImageSource *)source {
SDImageCacheType cacheType,
NSURL *imageURL) {
if (error) {
if (_onError) {
_onError(@{});
if (_onFastImageError) {
_onFastImageError(@{});
}
} else {
if (_onLoad) {
_onLoad(@{});
if (_onFastImageLoad) {
_onFastImageLoad(@{});
}
}
}];
Expand Down
4 changes: 2 additions & 2 deletions ios/FastImage/FFFastImageViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ - (FFFastImageView*)view {

RCT_EXPORT_VIEW_PROPERTY(source, FFFastImageSource);
RCT_EXPORT_VIEW_PROPERTY(resizeMode, RCTResizeMode);
RCT_EXPORT_VIEW_PROPERTY(onError, RCTDirectEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onLoad, RCTDirectEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onFastImageError, RCTDirectEventBlock);
RCT_EXPORT_VIEW_PROPERTY(onFastImageLoad, RCTDirectEventBlock);

@end

0 comments on commit e98bacc

Please sign in to comment.