Search code examples
javascriptreact-nativereact-native-flatliststickynative-base

Implementing sticky headers inside a FlatList in React Native


I tried to implement sticky headers inside a FlatList and encountered the following error: undefined is not an object (evaluating '_this3.state.stickyHeaderIndices')

Code Link (Snack): https://snack.expo.io/@cmcodes/forlorn-cake


Solution

  • This error is due to the fact that this is limited to use in your Explore Screen class, since you are using functional component to render list, you have to pass the sticky header data as you have passed the data i.e via props.

    You can check the updated code at

    https://snack.expo.io/1JtMGGDd4