Skip to content

Fix Image src prop support - #2852

Open
huytdps13400 wants to merge 1 commit into
necolas:masterfrom
huytdps13400:fix/2849-image-src-prop
Open

Fix Image src prop support#2852
huytdps13400 wants to merge 1 commit into
necolas:masterfrom
huytdps13400:fix/2849-image-src-prop

Conversation

@huytdps13400

Copy link
Copy Markdown

Summary

  • add the React Native Image src prop to the public Flow type
  • normalize src into the existing source pipeline without forwarding it to the root View
  • preserve the native contract that src takes precedence over source

Fixes #2849.

Root cause

Image only destructured and resolved source. The src prop therefore fell through to the root View, while image loading, caching, dimensions, background rendering, and the hidden accessibility image all continued to read source.

The component now selects one effective source up front (src when non-null, otherwise source) and leaves the existing loading/rendering pipeline unchanged.

Verification

  • Observed the focused regression fail before the implementation: expected src.png, received source.png.
  • Focused Image suite: 35 tests and 27 snapshots passed.
  • npm run test:
    • Flow: no errors
    • Prettier and ESLint: passed
    • DOM: 46 suites, 714 passed / 6 skipped, 213 snapshots
    • Node: 3 suites, 6 tests, 7 snapshots
  • npm run build -w react-native-web — ESM, CommonJS, and Flow outputs built successfully.
  • Chromium CDP runtime check on a local Next.js page:
    • src-only rendered the src URI
    • src + source rendered the src URI
    • console registry contained 0 errors and 0 warnings
  • git diff --check

Tested with the repository CI runtime, Node 16.20.1 / npm 8.19.4.

@codesandbox-ci

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit a7c5d9d:

Sandbox Source
react-native-web-examples Configuration

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.

Image component ignores src prop

1 participant