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

FlatList: initialScrollIndex broken in v0.16 #2030

Closed
hizo opened this issue May 24, 2021 · 2 comments
Closed

FlatList: initialScrollIndex broken in v0.16 #2030

hizo opened this issue May 24, 2021 · 2 comments
Labels
bug: react-native Bug associated with upstream React Native vendor code

Comments

@hizo
Copy link

hizo commented May 24, 2021

The problem
initialScrollIndex prop on FlatList stopped working from v0.16

How to reproduce
Simplified test case: https://codesandbox.io/s/nifty-hopper-44ntf

Steps to reproduce:

  1. open the above test case link
  2. observe an empty list with a scrollbar on the right (no signs of attempted scroll - the scrollbar is at the top of the list)
  3. scroll
  4. observe all items render at this point, with the scroll starting at the top of the list, instead of the provided index in initialScrollIndex prop

Expected behavior
FlatList renders items starting from the correct index provided in initialScrollIndex prop and the scrollbar shows correct position.

Environment (include versions). Did this work in previous versions?

  • React Native for Web (version): 0.16.3
  • React (version): 17.0.2
  • Browser: Google Chrome Version 90.0.4430.212

This worked in 0.15.x versions and below
Test case showcasing correct behaviour with rn-web v0.15.7: https://codesandbox.io/s/elegant-leaf-8yt3c

@hizo hizo changed the title FlatList: initialScrollIndex broke in v0.16 FlatList: initialScrollIndex broken in v0.16 May 24, 2021
@necolas necolas added the bug: react-native Bug associated with upstream React Native vendor code label May 24, 2021
@hizo
Copy link
Author

hizo commented Jul 27, 2021

Any update on this please? @necolas

@sirpy
Copy link

sirpy commented Aug 18, 2021

not working also on 0.17
as a workaround it is possible to pass this method to the "ref" prop
where selectedFeedIndex is the initial item

const getFlatListRef = useCallback(
    flatList => {
      if (flatList) {
        flatList.scrollToIndex({ animated: false, index: selectedFeedIndex })
      }
    },
    [selectedFeedIndex],
  )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: react-native Bug associated with upstream React Native vendor code
Projects
None yet
Development

No branches or pull requests

3 participants