Skip to content

fix: add number to source prop type to support require() assets#40

Merged
theashraf merged 1 commit intomainfrom
fix/source-prop-number-type
Mar 14, 2026
Merged

fix: add number to source prop type to support require() assets#40
theashraf merged 1 commit intomainfrom
fix/source-prop-number-type

Conversation

@theashraf
Copy link
Member

@theashraf theashraf commented Mar 14, 2026

Summary

  • Adds number to the source prop type in DotlottieReactNativeProps (both DotLottie.tsx and DotLottie.web.tsx) and updates the parseSource function signature in utils.ts to match
  • In React Native, require('./animation.lottie') returns a numeric asset ID — the runtime handling via Image.resolveAssetSource() already existed in parseSource, but TypeScript rejected the usage because number was missing from the type union
  • DotlottieNativeProps (the raw native view interface) is intentionally left unchanged — the source is always resolved to a string before being passed to the native bridge

Fixes #39

Test plan

  • Pass source={require('./animation.lottie')} to <DotLottie> — TypeScript should accept it without errors
  • Verify animation loads correctly at runtime via the resolved URI from Image.resolveAssetSource()

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
@changeset-bot
Copy link

changeset-bot bot commented Mar 14, 2026

⚠️ No Changeset found

Latest commit: e83d55c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@theashraf theashraf merged commit 1d4a40f into main Mar 14, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

source prop type should accept number to support require() assets

1 participant