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 not showing fallback icon when source prop becomes undefined/null

See original GitHub issue

Explain what you did I’m using an Avatar component with an image source and an icon as a fallback for a profile picture. If the image source is initially set to be undefined (i.e. no profile photo), the Avatar renders correctly with the icon, and if it has a source image, that renders correctly too.

Expected behaviour I would expect the Avatar to render the icon when the source prop is removed and the component rerenders.

Describe the bug If there is initially an image, and then it’s removed (use case here is a profile photo, and the user removing the profile picture), when the source prop becomes undefined, the avatar doesn’t render the icon, just a background with no icon and no image (tried using renderPlaceholderContent and it doesn’t render that either in this case).

Issue Analytics

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

github_iconTop GitHub Comments

11reactions
bravemaster619commented, Jul 29, 2020

According to doc, the following code should render placeholder with title MD:

// Avatar with Title
<Avatar rounded title="MD" />

However, it doesn’t show anything.

If you give some random string to source.uri, then it will render placeholder:

<Avatar
  rounded
  source={{uri: "foo.jpg"}}
  title="MD"
/>

I’ve tested in iOS and react-native-elements version is 2.0.1

9reactions
gouravpal1991commented, Jun 14, 2020

The issue is not fixed for android.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react.js Replace img src onerror - Stack Overflow
I am trying to replace the image with a default image if the image does not exist and there is a 404 error....
Read more >
How To Handle Async Data Loading, Lazy Loading, and Code ...
You'll load data using an asynchronous function that simulates a request to an external data source. First, create a component called ...
Read more >
The React Handbook – Learn React for Beginners
The React Handbook follows the 80/20 rule: learn in 20% of the time the 80% of a topic. I find this approach gives...
Read more >
React Suspense in Practice | CSS-Tricks
It means not rendering a UI that's partially complete. It means, if there are three data sources on the page, and one of...
Read more >
Stream Chat React Native - Docs - GitHub Pages
The ChatContext provides the following props: channel - currently active channel; client - client connection; connectionRecovering - whether or not ...
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