File tree Expand file tree Collapse file tree 3 files changed +30
-11
lines changed
packages/react-native-web/src Expand file tree Collapse file tree 3 files changed +30
-11
lines changed Original file line number Diff line number Diff line change 8
8
* @flow
9
9
*/
10
10
11
+ import type { ImageResult } from '../../modules/ImageLoader' ;
11
12
import type { ColorValue , GenericStyleProp } from '../../types' ;
12
13
import type { ViewProps } from '../View/types' ;
13
14
@@ -103,7 +104,7 @@ export type ImageStyle = {
103
104
} ;
104
105
105
106
export type ImageLoadingProps = { |
106
- onLoad ?: ( e : any ) => void ,
107
+ onLoad ?: ( e : ImageResult ) => void ,
107
108
onLoadStart ?: ( ) => void ,
108
109
onLoadEnd ?: ( ) => void ,
109
110
onError ?: ( { nativeEvent : { error : string } } ) => void ,
Original file line number Diff line number Diff line change 7
7
* @flow
8
8
*/
9
9
10
+ import type { ImageSource , ImageResult } from './types' ;
11
+
10
12
const dataUriPattern = / ^ d a t a : / ;
11
13
12
14
export class ImageUriCache {
13
15
static _maximumEntries : number = 256 ;
14
16
static _entries = { } ;
15
17
16
- static has ( uri : string ) : boolean {
18
+ static has ( uri : ?string ) : boolean {
19
+ if ( uri == null ) return false ;
20
+
17
21
const entries = ImageUriCache . _entries ;
18
22
const isDataUri = dataUriPattern . test ( uri ) ;
19
23
return isDataUri || Boolean ( entries [ uri ] ) ;
@@ -118,7 +122,7 @@ const ImageLoader = {
118
122
clearInterval ( interval ) ;
119
123
}
120
124
} ,
121
- has ( uri : string ) : boolean {
125
+ has ( uri : ? string ) : boolean {
122
126
return ImageUriCache . has ( uri ) ;
123
127
} ,
124
128
load (
@@ -205,13 +209,6 @@ const ImageLoader = {
205
209
}
206
210
} ;
207
211
208
- type ImageSource = { uri : string , headers ?: { [ key : string ] : string } } ;
209
-
210
- type ImageResult = {
211
- uri : string ,
212
- width : number ,
213
- height : number ,
214
- nativeEvent : Event
215
- } ;
212
+ export { ImageSource , ImageResult } from '. / types ';
216
213
217
214
export default ImageLoader ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright (c) Nicolas Gallagher.
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @flow
9
+ */
10
+
11
+ export type ImageSource = { |
12
+ uri : string ,
13
+ headers ?: { [ key : string ] : string }
14
+ | } ;
15
+
16
+ export type ImageResult = { |
17
+ uri : string ,
18
+ width : number ,
19
+ height : number ,
20
+ nativeEvent : Event
21
+ | } ;
You can’t perform that action at this time.
0 commit comments