Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: multiple components render issue in Avatar #3831

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

Merged

Conversation

@khushal87
Copy link
Member

@khushal87 khushal87 commented Aug 26, 2023
edited
Loading

Motivation

Fixes #3824

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Jest Unit Test
  • Checked with example app

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation using yarn docs-build-api
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Additional context

haeniya reacted with thumbs up emoji
Copy link

netlify bot commented Aug 26, 2023
edited
Loading

Deploy Preview for react-native-elements ready!

Name Link
🔨 Latest commit 8da88d0
🔍 Latest deploy log https://app.netlify.com/sites/react-native-elements/deploys/64f961e932f56300086a6a9d
😎 Deploy Preview https://deploy-preview-3831--react-native-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.


let componentToRender;

if (source) {
Copy link

@haeniya haeniya Aug 26, 2023
edited
Loading

Choose a reason for hiding this comment

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

If I unserstand correctly, in 4.0.0-rc.7, the title (if present) was shown in two different situations:

  1. As placeholder content when the image was rendering or could not be loaded
  2. As a fallback, if there was no image source passed (e.g. when the image source is undefined)
    See here: https://github.com/react-native-elements/react-native-elements/blob/v4.0.0-rc.7/packages/base/src/Avatar/Avatar.tsx#L206-L230

I wonder if this behavior is still the same with the latest changes.

There is a workaround for this (#3824 (comment)) but maybe we could keep the behavior the same? If this in on purpose and there are reasons to have it that way, it's fine for me. Just wanted to point that out.

Copy link
Member Author

@khushal87 khushal87 Aug 26, 2023

Choose a reason for hiding this comment

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

Hey @haeniya I totally understand your concern. I was checking the implementation of Placeholder content but regardless of this change, it doesn't seem to render the content even if I pass a placeholder content directly to the Image component(I doubt this ever worked before). The issue might be different and can be addressed differently.

This PR sought to fix the multiple components render issue(that was a mistake) and rendering placeholder still remains an issue.

Copy link
Member Author

@khushal87 khushal87 Aug 26, 2023

Choose a reason for hiding this comment

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

I think I would say using the imageProps would be a more viable option since we have it in Avatar. Users can use the imageProp and pass PlaceholerContent into it. No point in introducing a new prop in avatar for the same.

Copy link

Choose a reason for hiding this comment

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

It worked in 4.0.0-rc.7 but doesn't in the 4.0.0-rc.8 release. But you're right, it could be handled in a different issue/PR. I was just wondering if we need to refactor the code anyway, why not fix that too (to maybe speed up the process a bit).

I think I would say using the imageProps would be a more viable option since we have it in Avatar. Users can use the imageProp and pass PlaceholerContent into it. No point in introducing a new prop in avatar for the same.

I think the idea would not be to introduce a new prop but to make the title prop the PlaceholderContent if present. The linked workaround works for me but I need to put the title twice, as PlaceholderContent and as title. Was quite convenient to have this fallback automatically.

Copy link
Member Author

@khushal87 khushal87 Aug 26, 2023

Choose a reason for hiding this comment

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

Hey @haeniya, I have pushed the icon as the placeholder component as per the docs. Hope that helps. Please review the PR, if you can and let me know if it works. 😄

Copy link
Member Author

@khushal87 khushal87 Sep 3, 2023

Choose a reason for hiding this comment

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

Hey @haeniya, I am sorry for the confusion. I was luckily able to reproduce it now and I have pushed the fix. Hope that helps. Thanks 😄

haeniya reacted with hooray emoji
Copy link
Member Author

@khushal87 khushal87 Sep 6, 2023

Choose a reason for hiding this comment

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

@haeniya if you have tested it well, can we merge it?

Copy link

@haeniya haeniya Sep 6, 2023

Choose a reason for hiding this comment

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

@khushal87 I don't see any updates on the PR. Have you pushed your changes?

Copy link
Member Author

@khushal87 khushal87 Sep 7, 2023

Choose a reason for hiding this comment

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

Oh sorry my bad @haeniya, I thought I pushed it but I missed it somehow. Now I have done. Thanks 😄

Copy link

@haeniya haeniya Sep 7, 2023

Choose a reason for hiding this comment

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

@khushal87 I just tested it and it looks good to me. Thanks for the update. 👍

Copy link

codecov bot commented Aug 26, 2023
edited
Loading

Codecov Report

Merging #3831 (3b56302) into next (b5a95f6) will increase coverage by 0.03%.
Report is 1 commits behind head on next.
The diff coverage is 92.85%.

❗ Current head 3b56302 differs from pull request most recent head 8da88d0. Consider uploading reports for the commit 8da88d0 to get more accurate results

@@ Coverage Diff @@
## next #3831 +/- ##
==========================================
+ Coverage 79.87% 79.91% +0.03% 
==========================================
 Files 87 87 
 Lines 1824 1837 +13 
 Branches 814 809 -5 
==========================================
+ Hits 1457 1468 +11 
- Misses 362 364 +2 
 Partials 5 5 
Files Changed Coverage Δ
packages/base/src/Avatar/Avatar.tsx 95.74% <92.85%> (-4.26%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@arpitBhalla arpitBhalla merged commit 75d6ef7 into react-native-elements:next Sep 9, 2023
Copy link

l2aelba commented Dec 14, 2023

How to install or update to this fix ? @khushal87

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@arpitBhalla arpitBhalla Awaiting requested review from arpitBhalla

1 more reviewer

@haeniya haeniya haeniya left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Both Icon and image show up in the picture

AltStyle によって変換されたページ (->オリジナル) /