Skip to content

Commit fd8396e

Browse files
MoOxsgny
authored andcommitted
reason-react-native: Image onError (#420)
1 parent 5781d1b commit fd8396e

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎reason-react-native/src/components/Image.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ module DefaultSource = {
5050
external fromRequired: Packager.required => t = "%identity";
5151
};
5252
53+
type imageErrorEvent = Event.syntheticEvent({. "error": string});
54+
5355
type progress = {
5456
.
5557
"loaded": float,
@@ -59,6 +61,7 @@ type progress = {
5961
[@react.component] [@bs.module "react-native"]
6062
external make:
6163
(
64+
~onError: imageErrorEvent => unit=?,
6265
~onLayout: Event.layoutEvent => unit=?,
6366
~onLoad: unit => unit=?,
6467
~onLoadEnd: unit => unit=?,
@@ -86,14 +89,14 @@ external make:
8689
React.element =
8790
"Image";
8891
89-
type error;
92+
type sizeError;
9093
9194
[@bs.module "react-native"] [@bs.scope "Image"]
9295
external getSize:
9396
(
9497
~uri: string,
9598
~success: (~width: float, ~height: float) => unit,
96-
~failure: error => unit=?,
99+
~failure: sizeError => unit=?,
97100
unit
98101
) =>
99102
unit =
@@ -118,7 +121,6 @@ type asset = {
118121
};
119122
120123
[@bs.module "react-native"] [@bs.scope "Image"]
121-
external resolveAssetSource: Packager.required => asset =
122-
"resolveAssetSource";
124+
external resolveAssetSource: Source.t => asset = "resolveAssetSource";
123125
124126
```

‎reason-react-native/src/components/Image.re‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ module DefaultSource = {
4343
external fromRequired: Packager.required => t = "%identity";
4444
};
4545

46+
type imageErrorEvent = Event.syntheticEvent({. "error": string});
47+
4648
type progress = {
4749
.
4850
"loaded": float,
@@ -52,6 +54,7 @@ type progress = {
5254
[@react.component] [@bs.module "react-native"]
5355
external make:
5456
(
57+
~onError: imageErrorEvent => unit=?,
5558
~onLayout: Event.layoutEvent => unit=?,
5659
~onLoad: unit => unit=?,
5760
~onLoadEnd: unit => unit=?,
@@ -79,14 +82,14 @@ external make:
7982
React.element =
8083
"Image";
8184

82-
type error;
85+
type sizeError;
8386

8487
[@bs.module "react-native"] [@bs.scope "Image"]
8588
external getSize:
8689
(
8790
~uri: string,
8891
~success: (~width: float, ~height: float) => unit,
89-
~failure: error => unit=?,
92+
~failure: sizeError => unit=?,
9093
unit
9194
) =>
9295
unit =

0 commit comments

Comments
 (0)