Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Android Image defaultSource runtime error #49097

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mateoguzmana
Copy link
Contributor

Summary:

Fixes #49075

The Image defaultSource prop is causing a runtime error from 0.77 just by using it in the Image component (see error in the linked issue). This might be a regression from some changes in the prop processing logic from either #47710, #47713 or #47754.

Changelog:

[ANDROID] [FIXED] - Fix Image defaultSource runtime error

Test Plan:

  • Verify it doesn't throw any error on runtime anymore for Android.
  • iOS behaviour should not be impacted as changes are Android specific

In the RNTester, you can use the following component:

import * as React from 'react';
import {Image, View} from 'react-native';

function Playground() {
  return (
    <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
      <Image
        defaultSource={require('../../assets/bandaged.png')}
        source={{
          uri: 'https://i.natgeofe.com/n/548467d8-c5f1-4551-9f58-6817a8d2c45e/NationalGeographic_2572187_4x3.jpg',
        }}
        style={{width: 200, height: 200}}
      />
    </View>
  );
}

Also, this defaultSource prop is ignored in debug builds for Android (as per the docs) – but I've verified we get the defaultSource as a string, which is what we expect on the native side:

Screenshot of the Android logs

image

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 31, 2025
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jan 31, 2025
@mateoguzmana mateoguzmana marked this pull request as draft January 31, 2025 16:10
@cortinico cortinico requested a review from dmytrorykun January 31, 2025 16:17
@mateoguzmana mateoguzmana marked this pull request as ready for review January 31, 2025 16:21
Copy link
Contributor

@dmytrorykun dmytrorykun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepting to address the regression. Will try to fix this forward during next several weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0.77: Error when updating defaultsource property of <Image /> component (Android)
3 participants