Why would FlashList keyExtractor receive `undefined` in the first parameter

41 Views Asked by At

I have a simple key extractor that looks like

const keyExtractor = useCallback((props: TotpEntryProps, index: number) => {
  console.log(JSON.stringify({ label: props ? props.label : false , index, data }, null,2));
  return (props.issuer ? props.issuer + ":" : "") + props.label;
}, []);

Here are the log entries

{
  "label": "bar",
  "index": 0,
  "data": [
    {
      "label": "bar",
      "issuer": "zoo",
      "period": 30,
      "token": "314427",
      "timeRemaining": 2
    },
    {
      "label": "larry",
      "issuer": "zoo",
      "period": 60,
      "token": "2781",
      "timeRemaining": 2
    }
  ]
}

Then

{
  "label": false,
  "index": 0,
  "data": [
    {
      "label": "bar",
      "issuer": "zoo",
      "period": 30,
      "token": "314427",
      "timeRemaining": 2
    },
    {
      "label": "larry",
      "issuer": "zoo",
      "period": 60,
      "token": "2781",
      "timeRemaining": 2
    }
  ]
}

Not really sure what would be causing it. Is it a feature of FlashList? should keyExtractor return a null on specific occassions becuase I don't see it documented here

https://shopify.github.io/flash-list/docs/usage/#keyextractor

0

There are 0 best solutions below