question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Avatar source null no title initials back

See original GitHub issue

version 1.1.0

Explain what you did Hi I have a component which display my profile image from Firebase. If I have no image the initial was displayed. I have some interaction to delete the remote image or change the image. When I hit the delete button my avatar remove the image but it is empty. The initials title are not going back.

Expected behaviour I search a way to force back the initials if the source is set to undefined or null. I was thinking this is what it must happen.

My props are well passed to my child component and updated.

this is how I cal my child component :

<ProfileImage profile={this.props.profile} backgroundColor={theme.SECONDARY_COLOR} deletefunction={this.deleteImage} modifyfunction={this.pickImage} imgSource={this.state.imgSource} flexDirection={'row'} size={'large'} showEditButton={this.state.editMode} />

Here in my child component how I use ternary to set to undefined if no image are loaded. I use an alternative state to store the image before saving to firebase on save button press.

source={imgSource ? { uri: imgSource.uri } : profile.profileImg ? { uri: profile.profileImg } : undefined}

If I reload my app the title initials are back as intended.

Screenshots Before set an image

image

after set an image

image

when image is deleted

image

Your Environment (please complete the following information):

software version
react-native-elements 1.1.0
react-native 0.59.3

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
iRoachiecommented, Aug 22, 2019

The fix for this was made on the next branch so it isn’t released on npm as yet. If you want to use this version at the moment you can do:

yarn add https://github.com/react-native-training/react-native-elements.git\#next
0reactions
Cchumicommented, Aug 31, 2019

Great thanks again

Cchumi

Read more comments on GitHub >

github_iconTop 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 >
Avatar | Mantine
Display user profile image, initials or fallback icon. ... If src prop is not set, equals to null or image cannot be loaded,...
Read more >
CircleAvatar class - material library - Flutter - Dart API docs
A circle that represents a user. Typically used with a user's profile image, or, in the absence of such an image, the user's...
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
Avatar ; title, string, name or value, The title attribute used on the avatar img tag. If not set we will fallback to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found