hyochan / react-native-masonry-list

The Masonry List implementation which has similar implementation as the `FlatList` in React Native
MIT License
393 stars 55 forks source link

MasonryList Component typing improvements. #52

Open CarmineRumma opened 1 year ago

CarmineRumma commented 1 year ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Here is the diff that avoid typing's warnings on props data and renderItem:

diff --git a/node_modules/@react-native-seoul/masonry-list/lib/index.d.ts b/node_modules/@react-native-seoul/masonry-list/lib/index.d.ts
index dc67ceb..980b1c6 100644
--- a/node_modules/@react-native-seoul/masonry-list/lib/index.d.ts
+++ b/node_modules/@react-native-seoul/masonry-list/lib/index.d.ts
@@ -1,5 +1,5 @@
 import type { Omit, RefreshControlProps, ScrollViewProps, StyleProp, ViewStyle } from 'react-native';
-import { ScrollView } from 'react-native';
+import { ListRenderItem, ScrollView } from "react-native";
 import type { MutableRefObject, ReactElement } from 'react';
 import React from 'react';
 interface Props<T> extends Omit<ScrollViewProps, 'refreshControl'> {
@@ -11,11 +11,8 @@ interface Props<T> extends Omit<ScrollViewProps, 'refreshControl'> {
     onEndReached?: () => void;
     onEndReachedThreshold?: number;
     style?: StyleProp<ViewStyle>;
-    data: T[];
-    renderItem: ({ item, i }: {
-        item: T;
-        i: number;
-    }) => ReactElement;
+    data: ReadonlyArray<T>;
+    renderItem: ListRenderItem<ItemT> | null | undefined;
     LoadingView?: React.ComponentType<any> | React.ReactElement | null;
     ListHeaderComponent?: React.ReactNode | null;
     ListEmptyComponent?: React.ComponentType<any> | React.ReactElement | null;
hyochan commented 1 year ago
Screenshot 2023-01-24 at 7 15 33 PM

I am seeing this when I apply this patch 🤔