Skip to content

Commit 1d4a40f

Browse files
authored
fix: add number to source prop type to support require() assets (#40)
The source prop type now accepts number in addition to string and { uri: string }, matching React Native's require() asset resolution which returns numeric asset IDs. The runtime handling via Image.resolveAssetSource() already existed in parseSource(); this change aligns the TypeScript types with that behavior. Fixes #39
1 parent cf678bb commit 1d4a40f

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/DotLottie.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ interface DotlottieNativeProps {
135135
}
136136

137137
interface DotlottieReactNativeProps {
138-
source: string | { uri: string };
138+
source: string | number | { uri: string };
139139
loop?: boolean;
140140
autoplay?: boolean;
141141
speed?: number;

src/DotLottie.web.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export type Dotlottie = {
4646
};
4747

4848
interface DotlottieReactNativeProps {
49-
source: string | { uri: string };
49+
source: string | number | { uri: string };
5050
loop?: boolean;
5151
autoplay?: boolean;
5252
speed?: number;

src/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { Image } from 'react-native';
22

3-
function parseSource(source: { uri: string } | string): string | undefined {
3+
function parseSource(
4+
source: { uri: string } | string | number
5+
): string | undefined {
46
const uri = (source as any).uri;
57

68
if (typeof source === 'object' && uri) {

0 commit comments

Comments
 (0)