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

[iOS] Fabric: Support defaultSource prop of Image component #46554

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

Conversation

zhongwuzw
Copy link
Contributor

Summary:

We missed defaultSource support of Image in Fabric, so let's add it.

Changelog:

[IOS] [FIXED] - Fabric: Support defaultSource prop of Image component

Test Plan:

RNTester Image defaultSource example worked in Fabric.

@facebook-github-bot facebook-github-bot added 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. labels Sep 18, 2024
Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

Some small nits to update.
I'm not super familiar with the Image logic, once we fix the nits, I'll import it and ask for few more people to have a look at it.

Comment on lines 133 to 134
if (strongSelf) {
if (!strongSelf->_imageView.image) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (strongSelf) {
if (!strongSelf->_imageView.image) {
if (strongSelf && !strongSelf->_imageView.image) {

but what if we have an image already? I mean, what happens if we change the imageSource prop?

Copy link
Contributor Author

@zhongwuzw zhongwuzw Sep 25, 2024

Choose a reason for hiding this comment

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

If we have an image already, we would not reset default image and just only to load new image source. The same logic as old arch.

RCTImageComponentView *strongSelf = weakSelf;
if (strongSelf) {
if (!strongSelf->_imageView.image) {
strongSelf->_imageView.image = finalImage;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we emit an OnLoadEnd event here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same as old arch, we only fire image load events for image source.

@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

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.

3 participants