-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
fix: multiple components render issue in Avatar #3831
Conversation
✅ Deploy Preview for react-native-elements ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
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:
- As placeholder content when the image was rendering or could not be loaded
- 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@haeniya
haeniya
Aug 26, 2023
There was a problem hiding this comment.
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
imagePropand 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.
There was a problem hiding this comment.
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. 😄
There was a problem hiding this comment.
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 😄
There was a problem hiding this comment.
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?
@haeniya
haeniya
Sep 6, 2023
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 😄
@haeniya
haeniya
Sep 7, 2023
There was a problem hiding this comment.
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. 👍
Codecov Report
@@ 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
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
l2aelba
commented
Dec 14, 2023
How to install or update to this fix ? @khushal87
Uh oh!
There was an error while loading. Please reload this page.
Motivation
Fixes #3824
Fixes # (issue)
Type of change
How Has This Been Tested?
exampleappChecklist
yarn docs-build-apiAdditional context