Skip to content

Image component ignores src prop #2849

Description

@shayypy

Is there an existing issue for this?

  • I have searched the existing issues

Describe the issue

I have been using the src prop for network images in my native app as it is more brief than using source={{ uri: networkUrl }}, but react-native-web silently drops this prop and simply renders no image when it is used.

Expected behavior

react-native-web should render the image using the URI passed to src, taking precedence over source, if it is passed, per https://reactnative.dev/docs/image#src

Steps to reproduce

react-native-web 0.21.2
Create an image element and pass a network URI as its src: <Image src={uri} /> and compare to another element with the same URI, but passed to source: <Image source={{ uri }} />. Both render identically on native platforms, but not on web.

Test case

https://codesandbox.io/p/devbox/priceless-pasteur-6f9h79

Additional comments

I would be happy to submit a PR fixing this wherein src is also accepted here and transforms to { uri: src } for the remainder of the logic, should this be confirmed as unintentional behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions