-
I'm not sure if JSON.stringify is a better option for large JavaScript objects than simple string concatenation. [After repo quick search...] keyExtractor before: const keyExtractor = (item: Item, index: number) => {
switch (item.type) {
case "uno":
return item.type;
case "dos":
return item.type + index;
case "tres":
return item.content.id.toString();
}
}; keyExtractor after: const keyExtractor = (item: Item) => {
switch (item.type) {
case "uno":
return item.type;
case "dos":
return JSON.stringify(item);
case "tres":
return item.content.id.toString();
}
}; Date.now() is not an option, is it? Will the keyExtractor be executed later? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
It doesn't because of problems that it introduced. In general, items were incorrectly positioned after a new data array was provided containing items in a different order than before. Because keys were assigned based on index, thus they weren't related to the item itself, we could observer incorrect animations e.g. during view addition/removal - see the example below:
You included comparison of 2
No, you shouldn't use anything that is not related to the item, so
What do you mean by asking if it will be executed later? |
Beta Was this translation helpful? Give feedback.
It doesn't because of problems that it introduced. In general, items were incorrectly positioned after a new data array was provided containing items in a different order than before. Because keys were assigned based on index, thus they weren't related to the item itself, we could observer incorrect animations e.g. during view addition/removal - see the example below:
Screen.Recording.2025-03-25.at.00.39.51.mp4
Screen.Recording.2025-03-25.at.00.39.24.mp4
You included comparison of 2
keyExtractor
implementations. Did you use the first one with…