Skip to content
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

List not rendering items after initial data array is empty #784

Closed
freddy-eturi opened this issue Mar 9, 2023 · 14 comments · Fixed by #1236
Closed

List not rendering items after initial data array is empty #784

freddy-eturi opened this issue Mar 9, 2023 · 14 comments · Fixed by #1236
Assignees

Comments

@freddy-eturi
Copy link

How to reproduce:

  1. Have an empty data set. Use EmptyListComponent
  • EmptyListComponent will render correctly.
  1. Add an item to the data set without destroying the FlashList i.e via state change.
  • EmptyListComponent will disappear, but new item is not rendered.

However if the data set is not empty on initialization then everything works as expected.

So if the data array has an item it will render the item. If the item is removed then EmptyListComponent is rendered as expected.
Then If a new item is added then it will also render as expected.

This leads me to believe that there is an issue that occurs when initializing a FlashList with an empty data set.

Might be related to: #757 however I wasn't using a horizontal list

@freddy-eturi freddy-eturi changed the title List not calling RenderItem when initial data array is empty List not rendering items after initial data array is empty Mar 9, 2023
@naqvitalha
Copy link
Collaborator

Can you provide an expo snack which reproduces this issue? It'll help with debugging this quickly.

@fortmarek
Copy link
Contributor

Can you also post FlashList version you are using?

@freddy-eturi
Copy link
Author

I'll try to create an expo as soon as I can.

I am using 1.4.0

@wahidshadab
Copy link

This is happening to me as well,
I am using 1.5.0
@naqvitalha @fortmarek The issue for me is with the prop estimatedListSize. When I remove the estimatedListSize it works fine.
The estimatedListSize prop on my code looks like

estimatedListSize={{
        height: Dimensions.get('window').height,
        width: Dimensions.get('window').width,
      }}

@ItsFlash10
Copy link

This is happening to me as well, I am using 1.5.0 @naqvitalha @fortmarek The issue for me is with the prop estimatedListSize. When I remove the estimatedListSize it works fine. The estimatedListSize prop on my code looks like

estimatedListSize={{
        height: Dimensions.get('window').height,
        width: Dimensions.get('window').width,
      }}

You're correct; I'm facing the same issue, but removing it renders a white screen for a second after the data is fetched from the API. Please lemme know if you find a solution that can handle both cases.
PS: Using estimatedListSize conditionally for the time being.

@shadabwahidullah
Copy link

@ItsFlash10 No unfortunately I did not find any solution, instead I opted to show a loader while the data is being fetched from the API.

@ItsFlash10
Copy link

ItsFlash10 commented Aug 30, 2023

@ItsFlash10 No unfortunately I did not find any solution, instead I opted to show a loader while the data is being fetched from the API.

@shadabwahidullah It worked for me and also adding a loader didn't help in my case as the issue is after the data is being populated, so the blank screen appears after the data is fetched from the API.

@zRelux
Copy link

zRelux commented Sep 12, 2023

Same issues using estimatedListSize

@baesumin
Copy link

+1

@humaidk2
Copy link

humaidk2 commented Nov 7, 2023

Still facing this
"@shopify/flash-list": "1.5.0",
"react-native": "0.72.5"

this hack does fix it, but its a hack

if (data.length === 0) {
  return renderEmpty();
}

@linxianxi
Copy link

same here

@PankajPunia
Copy link

Facing the same issue, if i provide estimatedListSize, flashlist does not render the items and i see blank screen. Happening on android only

@salim-m
Copy link

salim-m commented Apr 3, 2024

+1

@VadymVashchuk
Copy link

Just faced same issue. I was sure that I have tested in my chat app such case when user send message to the empty chat. And I was sure that everything works fine. And today new messages are ignored... I forgot that I've recently added this prop - estimatedListSize to my FlashLIst component and broke this case with this prop:D Always fun to work with libraries in RN! When you fix an issue you immediately get another one to fix:D

For now I think this solution works fine:

          const { height, width } = useWindowDimensions();

          estimatedListSize={!data.length ? null : {
          height: height,
          width: width,
        }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.