Skip to content

Commit ce4dfcc

Browse files
Always render all items if initialKey is null
1 parent b438b36 commit ce4dfcc

File tree

1 file changed

+2
-3
lines changed
  • src/components/InvertedFlatList/BaseInvertedFlatList

1 file changed

+2
-3
lines changed

src/components/InvertedFlatList/BaseInvertedFlatList/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ function BaseInvertedFlatList<T>(props: BaseInvertedFlatListProps<T>, ref: Forwa
3838
if (initialScrollKey) {
3939
return initialScrollKey;
4040
}
41-
const initialItem = data.at(0);
42-
return initialItem ? keyExtractor(initialItem, 0) : null;
41+
return null;
4342
});
4443
const [isInitialData, setIsInitialData] = useState(true);
45-
const currentDataIndex = useMemo(() => data.findIndex((item, index) => keyExtractor(item, index) === currentDataId), [currentDataId, data, keyExtractor]);
44+
const currentDataIndex = useMemo(() => (currentDataId === null ? 0 : data.findIndex((item, index) => keyExtractor(item, index) === currentDataId)), [currentDataId, data, keyExtractor]);
4645
const displayedData = useMemo(() => {
4746
if (currentDataIndex <= 0) {
4847
return data;

0 commit comments

Comments
 (0)