Skip to content

Commit 4374336

Browse files
committed
feat: use native component and fix spec
1 parent 756350f commit 4374336

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

src/FastImageViewNativeComponent.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {
44
Float,
55
WithDefault,
66
BubblingEventHandler,
7+
Int32,
78
} from 'react-native/Libraries/Types/CodegenTypes';
89

910
type Headers = Readonly<{}>
@@ -23,8 +24,8 @@ type OnLoadEvent = Readonly<{
2324
}>
2425

2526
type OnProgressEvent = Readonly<{
26-
loaded: Float,
27-
total: Float,
27+
loaded: Int32,
28+
total: Int32,
2829
}>
2930

3031
interface NativeProps extends ViewProps {
@@ -34,7 +35,7 @@ interface NativeProps extends ViewProps {
3435
onFastImageLoadStart?: BubblingEventHandler<Readonly<{}>>,
3536
onFastImageProgress?: BubblingEventHandler<OnProgressEvent>,
3637
source?: FastImageSource,
37-
defaultSource?: string,
38+
defaultSource?: string | null,
3839
resizeMode?: WithDefault<'contain' | 'cover' | 'stretch' | 'center', 'cover'>,
3940
tintColor?: ColorValue,
4041
}

src/index.tsx

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
View,
44
Image,
55
NativeModules,
6-
requireNativeComponent,
76
StyleSheet,
87
FlexStyle,
98
LayoutChangeEvent,
@@ -16,6 +15,7 @@ import {
1615
ViewProps,
1716
ColorValue,
1817
} from 'react-native'
18+
import FastImageView from './FastImageViewNativeComponent';
1919

2020
export type ResizeMode = 'contain' | 'cover' | 'stretch' | 'center'
2121

@@ -260,19 +260,4 @@ const styles = StyleSheet.create({
260260
},
261261
})
262262

263-
// Types of requireNativeComponent are not correct.
264-
const FastImageView = (requireNativeComponent as any)(
265-
'FastImageView',
266-
FastImage,
267-
{
268-
nativeOnly: {
269-
onFastImageLoadStart: true,
270-
onFastImageProgress: true,
271-
onFastImageLoad: true,
272-
onFastImageError: true,
273-
onFastImageLoadEnd: true,
274-
},
275-
},
276-
)
277-
278263
export default FastImage

0 commit comments

Comments
 (0)