Skip to content

Commit

Permalink
Handle undefined callbacks ios (#5)
Browse files Browse the repository at this point in the history
* update glide license url

* Handle undefined callbacks in setters on iOS native module
@onurersel

---------

Co-authored-by: Lu <[email protected]>
  • Loading branch information
Yann-prak and Lu committed Jul 18, 2024
1 parent 0b4f475 commit 73bd76e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
### ⚠️ This is a fork of https://github.com/DylanVann/react-native-fast-image. All credit goes to the original author.

<h1 align="center">
🚩 FastImage
</h1>
Expand Down Expand Up @@ -186,7 +187,6 @@ e.g. `onLoad={e => console.log(e.nativeEvent.width, e.nativeEvent.height)}`

Called on an image fetching error or when source is malformed (i.e: empty or null).


---

### `onLoadEnd?: () => void`
Expand Down Expand Up @@ -268,7 +268,7 @@ Thanks to [@mobinni](https://github.com/mobinni) for helping with the conceptual

- FastImage - MIT © [Dream11](https://github.com/dream11)
- SDWebImage - `MIT`
- Glide - BSD, part MIT and Apache 2.0. See the [LICENSE](https://github.com/bumptech/glide/blob/master/license) file for details.
- Glide - BSD, part MIT and Apache 2.0. See the [LICENSE](https://github.com/bumptech/glide/blob/master/LICENSE) file for details.

[build-badge]: https://github.com/dream-sports-labs/react-native-fast-image/workflows/CI/badge.svg
[build]: https://github.com/dream-sports-labs/react-native-fast-image/actions?query=workflow%3ACI
Expand Down
10 changes: 6 additions & 4 deletions ios/FastImage/FFFastImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,31 @@ - (void) setResizeMode: (RCTResizeMode)resizeMode {

- (void) setOnFastImageLoadEnd: (RCTDirectEventBlock)onFastImageLoadEnd {
_onFastImageLoadEnd = onFastImageLoadEnd;
if (self.hasCompleted) {
if (self.hasCompleted && _onFastImageLoadEnd) {
_onFastImageLoadEnd(@{});
}
}

- (void) setOnFastImageLoad: (RCTDirectEventBlock)onFastImageLoad {
_onFastImageLoad = onFastImageLoad;
if (self.hasCompleted) {
if (self.hasCompleted && _onFastImageLoad) {
_onFastImageLoad(self.onLoadEvent);
}
}

- (void) setOnFastImageError: (RCTDirectEventBlock)onFastImageError {
_onFastImageError = onFastImageError;
if (self.hasErrored) {
if (self.hasErrored && _onFastImageError) {
_onFastImageError(@{});
}
}

- (void) setOnFastImageLoadStart: (RCTDirectEventBlock)onFastImageLoadStart {
if (_source && !self.hasSentOnLoadStart) {
_onFastImageLoadStart = onFastImageLoadStart;
onFastImageLoadStart(@{});
if (onFastImageLoadStart) {
onFastImageLoadStart(@{});
}
self.hasSentOnLoadStart = YES;
} else {
_onFastImageLoadStart = onFastImageLoadStart;
Expand Down

0 comments on commit 73bd76e

Please sign in to comment.