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.

How to avoid flickering when Avatar re-render again and again.

See original GitHub issue

Explain what you did

Expected behavior

not show to user that, avatar re-render again and again.

Describe the bug

To Reproduce

               <Avatar
                      rounded
                      size={height/6}
                      defaultSource ={DummyUser}
                      source ={profileimageTutor ? {uri:profileimage} : DummyUser} 
                      defaultSource ={profileimageTutor ? {uri:profileimage} : DummyUser} 
                      icon={{name: 'user', type:'antdesign'}}
                      containerStyle={{borderWidth:3, borderColor:Colors.Grey89, elevation:2}}
                      resizeMethod="scale"
                      resizeMode="cover"
                  />

Screenshots

  1. Screenshot 2020-01-06 at 3 16 06 PM
  2. Screenshot 2020-01-06 at 3 15 43 PM

Your Environment (please complete the following information):

| software | version | yarn install v1.16.0 | --------------------- | ------- | “react-native-elements”: “^1.2.7”, “react”: “16.9.0”, “react-native”: “0.59.9”,

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:34

github_iconTop GitHub Comments

6reactions
raRaRacommented, Feb 13, 2020

I can confirm that wrapping the component with React.memo solved the issue for me, since the component will be cached and not re-rendered unless the image changes.

5reactions
raRaRacommented, Feb 25, 2020

If you have a functional component then you can export it like this:

const FunctionalComponent= () => {
    return (<h1>Hello world</h1>)
}

export default React.memo(FunctionalComponent)

This will only cause the component to re-render if any of the props have changed.

If you use class component then you can extend it from PureComponent instead of Component:

class ClassComponent extends React.PureComponent {

PureComponent will work like React.memo

Read more comments on GitHub >

github_iconTop Results From Across the Web

Avoid flickering images when state change? : r/reactjs - Reddit
My component maps it and returns a message component for each message (this component has an avatar image and the message content).
Read more >
React Re-Render Causes Flickering : How can i fix this?
Re-render is fine tho however my images are flickering on mobile browser. ... to go into "Prop Drilling" again which is not a...
Read more >
Fix the slow render before you fix the re-render - Kent C. Dodds
Stop punching yourself in the face every time you blink. Fix your slow renders first. Then deal with the "unnecessary re-renders" (if you...
Read more >
zoom causing screen to flicker - Ramozzi & Friends
Press the Power button to start the computer and repeatedly press the F10 key to ... 2021-11-12 12:34 PM. screen flickering will stop...
Read more >
Flickering / Flashing / Refreshing UI?
If I switch back to first opened window (or leave both windows open each in separate screen and just go over it with...
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