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
How to avoid flickering when Avatar re-render again and again. #2233
Comments
Hey @Biplovkumar The I found this comment facebook/react-native#981 (comment) about how to fix this flickering on the |
|
Any update on Avatar issues. |
Hi, I got the same issue here. Any update guys ? |
Same issue here, only happens on iOS for me. I'm going to try to put the component into its own component wrapped with |
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. |
Hi same issue here how do you use React.memo ? |
If you have a functional component then you can export it like this:
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
|
The permanent fix would probably be to do this internally in the Avatar component, to avoid unnecessary re-renders. Or fix whatever is causing it to flicker with each re-render. Very likely some |
@Biplovkumar @raRaRa @Cchumi Could you guys reproduce this issue with a really simple example on https://snack.expo.io/ ? With a simple component update its state and the Avatar flickering ? I couldn't reproduce this locally |
I am unable to reproduce this behavior on codesandbox.... Other strange thing for me is : Also I pass my component to PureComponent but it does not solve the issue. |
@Cchumi Then your component is re-rendering for some reason, e.g. if a prop has changed. |
just make a simple snack: |
@xavier-villelegier find out what causing this on ios only. React native on ios only has a cache property. In avatar component it's like it is set to reload. |
@ozerty Oh okay I see ! If you manage to fix this by changing something in the |
@xavier-villelegier I think your message was destinated to @Cchumi |
Just to let you know, I fixed this issue by doing memoization on my avatar component. |
@xavier-villelegier I try but cannot get a fix... cache settings is not a good idea. |
@rob5408 Using React functional component :
And then in my render :
Hope it will help some of you. |
It's not the solution. |
@Biplovkumar I agree. |
Hey guys @Biplovkumar @ozerty @Cchumi Could you please use the branch You can test by adding this to your
It works for me |
@xavier-villelegier Good job ! It's fixed for me too. |
@xavier-villelegier Nice. |
Works for me too but it breaks the input component on input field. It just don’t show my inputcomponent. When I reverted back to latest 1.2.7 everything works |
@Cchumi We changed to |
@xavier-villelegier Thanks for your answer :). I didn't see that |
I got far less flickering using (issue-2233-fix-avatar-flicker), mostly gone, but then it seemed to break the width and height property of the Overlay component. These props were then not being honored (or couldn't be set). Reverted back to 1.2.7. Hopefully will be fixed in the next update. |
this did not work on me still same, should i clear some cache or something ? or install that package to react-native-elements directory ? what did i do wrong ? |
Will be released in 2.0.1 |
I know the answer is late, but posting my answer here in case someone still want to find a solution and because I've found this drives some traffic. A simple workaround is to add a css transition property to the image like the below:
it does not prevent the image re-rendering, but at least it does prevent image flickering. |
Tried to resolve the issue, but found that |
|
I am also facing flicker image of base64 data from websocket. Can someone help me |
using |
Explain what you did
Expected behavior
not show to user that, avatar re-render again and again.
Describe the bug
To Reproduce
Screenshots
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",
The text was updated successfully, but these errors were encountered: