Avatar not using fallback on title when source is undefined
See original GitHub issueExplain what you did
Set source to undefined to show the placeholder title
Expected behavior
If source is undefined fallback on the defined title as placeholder
Describe the bug
Avatar does not fallback to placeholder title when source set to undefined.
To Reproduce
Example:
const [avatar, setAvatar] = useState({uri: 'https://s3.amazonaws.com/uifaces/faces/twitter/ladylexy/128.jpg' });
const removeAvatar = () => {
setAvatar(undefined);
}
<Avatar
rounded
size="large"
title={benutzerName.charAt(0)}
containerStyle={styles.avatarContainer}
showAccessory
onAccessoryPress={removeAvatar}
source={avatar}
/>
Screenshots
Avatar with image:
Avatar with source set to undefined:
Your Environment (please complete the following information):
software | version |
---|---|
react-native-elements | 2.0.4 |
react-native | 0.63.1 |
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
avatar not showing fallback icon when source prop becomes ...
I'm using an Avatar component with an image source and an icon as a fallback for a profile picture. If the image source...
Read more >react-native-elements avatar - problem with fallback to title on ...
I'm using a cloud based storage for avatar images. If an image for a user doesn't exist I want to fallback to the...
Read more >react-avatar - npm
Start using react-avatar in your project by running `npm i react-avatar`. ... If not set we will fallback to either name or value....
Read more >Avatars - Salesforce Lightning Design System | React
If the imgSrc prop is undefined, and if a label or initials prop is available, the fallback avatar will render with initials.
Read more >Avatar API - Material UI - MUI
API reference docs for the React Avatar component. Learn about the props, CSS, ... Used to render icon or text elements inside the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@daryllukas is correct. The placeholder background is
transparent
and the default text color iswhite
. So you either need to change the default text color style in the Avatar, or change your background color.avatar seems quite broken on v2, even the basic examples from docs doesn’t work, e.g.