I'm making a chat interface in ReactJS, and each item in the chat log displays the same avatar icon over and over again. Currently the problem I'm facing is that when new items are added the chat log, this image blinks in every list item, which does not look very presentable.
I want to know if there is a way to reuse the Component
(most probably not) or the bitmap data, so that once loaded in memory, it can be shown more quickly without a perceivable blink. I have tried using data URL, but not to much avail.
Per request in comments further details:
I have a separate Component
to show each chat log item. It contains an Image
component to show the avatar.
On the top log I'm using a FlatList
and in the renderItem
I'm rendering the said chat log component. Whenever any message is sent or received it is appended to the array that the data
in the FlatList
is pointing to.
Whenever an item is added the list gets re-rendered causing the Image
to be created again (I have searched but haven't found any good away of appending items to a FlatList
without affecting existing children). Therefore I believe the solution lies in making the image load faster so that the re-render is not so perceivable.
One reason I think of the flickering is if you reassign the key
of list items and forcing
it to re-render. Check if there is any such case. Thats one of the main reasons component to re-render on listviews.