Search code examples
react-nativereact-native-sectionlist

Does the keyextractor for SectionList need to return a unique value for the whole data or just the section?


The keyextractor on the SectionList defines a signature that only accepts the item. Does the keyextractor for SectionList need to return a unique value for the whole data or just the section?


Solution

  • Used to extract a unique key for a given item at the specified index. Key is used for caching and as the react key to track item re-ordering. The default extractor checks item.key, then item.id, and then falls back to using the index, like React does.

    It is unique per section. It needs to be unique if you want to prevent any unwanted UI flicks during re-rendering.