Fix onLoad and onError on iOS.

This commit is contained in:
Dylan Vann 2017-04-18 11:57:18 -04:00
parent a891bcf014
commit e98bacc84f
4 changed files with 11 additions and 9 deletions

View File

@ -44,6 +44,8 @@ const FastImageSourcePropType = PropTypes.shape({
FastImage.propTypes = {
...View.propTypes,
source: FastImageSourcePropType,
onFastImageError: PropTypes.func,
onFastImageLoad: PropTypes.func,
}
FastImage.defaultProps = {
@ -53,7 +55,7 @@ FastImage.defaultProps = {
}
const FastImageView = requireNativeComponent('FastImageView', FastImage, {
nativeOnly: { onError: true, onLoad: true },
nativeOnly: { onFastImageError: true, onFastImageLoad: true },
})
export default FastImage

View File

@ -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;

View File

@ -42,12 +42,12 @@
SDImageCacheType cacheType,
NSURL *imageURL) {
if (error) {
if (_onError) {
_onError(@{});
if (_onFastImageError) {
_onFastImageError(@{});
}
} else {
if (_onLoad) {
_onLoad(@{});
if (_onFastImageLoad) {
_onFastImageLoad(@{});
}
}
}];

View File

@ -14,7 +14,7 @@ RCT_EXPORT_MODULE(FastImageView)
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