React native flatlist initial scroll to bottom

I had similar issue. If you want to have you chat messages start at the bottom, you could set “inverted” to true and display your messages and time tag in an opposite direction. Check here for “inverted” property for FlatList. https://facebook.github.io/react-native/docs/flatlist#inverted If you want to have you chat messages start at the top, which is … Read more

FlatList ScrollView Error on any State Change – Invariant Violation: Changing onViewableItemsChanged on the fly is not supported

Based on @woodpav comment. Using functional components and Hooks. Assign both viewabilityConfig to a ref and onViewableItemsChanged to a useCallback to ensure the identities are stable and use those. Something like below: const onViewCallBack = React.useCallback((viewableItems)=> { console.log(viewableItems) // Use viewable items in state or as intended }, []) // any dependencies that require the … Read more

Scroll to end of FlatList after displaying the keyboard

I’m making a chat component and I want about the same things. Did it like this: <FlatList ref={ref => this.flatList = ref} onContentSizeChange={() => this.flatList.scrollToEnd({animated: true})} onLayout={() => this.flatList.scrollToEnd({animated: true})} … /> Keyboard popping up triggers a layout, so that’s fixed. New chat messages arriving trigger content changes, so it also scrolls to the bottom … Read more