File tree 4 files changed +13
-13
lines changed
src/common/components/ListView
4 files changed +13
-13
lines changed Original file line number Diff line number Diff line change 25
25
"query-string" : " ^7.0.1" ,
26
26
"react" : " 17.0.1" ,
27
27
"react-fast-compare" : " ^3.2.0" ,
28
- "react-hook-form" : " ^7.11.0 " ,
29
- "react-i18next" : " ^11.11.2 " ,
28
+ "react-hook-form" : " ^7.11.1 " ,
29
+ "react-i18next" : " ^11.11.3 " ,
30
30
"react-native" : " 0.64.1" ,
31
31
"react-native-dotenv" : " ^3.1.1" ,
32
32
"react-native-error-boundary" : " ^1.1.10" ,
40
40
"react-native-unimodules" : " ^0.14.5" ,
41
41
"react-native-vector-image" : " ^0.3.2" ,
42
42
"react-navigation-heavy-screen" : " ^1.2.1" ,
43
- "react-query" : " ^3.18.1 " ,
43
+ "react-query" : " ^3.19.0 " ,
44
44
"recoil" : " ^0.3.1"
45
45
},
46
46
"devDependencies" : {
Original file line number Diff line number Diff line change 1
1
import { ListRenderItem } from 'react-native' ;
2
2
3
- export interface IRefreshListViewProps {
3
+ export interface IRefreshListViewProps < ItemT > {
4
4
refreshState : number ;
5
5
onHeaderRefresh ?: ( state : number ) => void ;
6
6
onFooterRefresh ?: ( state : number ) => void ;
7
- data : any [ ] ;
7
+ data : ReadonlyArray < ItemT > ;
8
8
9
9
listRef ?: any ;
10
10
@@ -18,14 +18,14 @@ export interface IRefreshListViewProps {
18
18
footerNoMoreDataComponent ?: any ;
19
19
footerEmptyDataComponent ?: any ;
20
20
21
- renderItem : ListRenderItem < any > | null | undefined ;
21
+ renderItem : ListRenderItem < ItemT > | null | undefined ;
22
22
}
23
23
24
- export type IListViewProps = {
24
+ export type IListViewProps < ItemT > = {
25
25
/* Is there more */
26
26
hasMore : boolean ;
27
27
/* List data */
28
- dataSource : any [ ] ;
28
+ dataSource : ReadonlyArray < ItemT > ;
29
29
/* Pull-down refresh function */
30
30
refresh : ( ) => void ;
31
31
/* Pull up and load product data function */
@@ -35,7 +35,7 @@ export type IListViewProps = {
35
35
/* Empty data display */
36
36
emptyDataComponent ?: React . ReactNode ;
37
37
/* Render ui */
38
- renderRow : ListRenderItem < any > | any ;
38
+ renderItem : ListRenderItem < ItemT > | null | undefined ;
39
39
/* Remaining parameters */
40
40
[ key : string ] : any ;
41
41
} ;
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ export enum RefreshState {
19
19
}
20
20
let callOnScrollEnd : boolean ;
21
21
22
- const RefreshListView = ( props : IRefreshListViewProps ) => {
22
+ const RefreshListView = < ItemT extends { } > ( props : IRefreshListViewProps < ItemT > ) => {
23
23
function onHeaderRefresh ( ) {
24
24
if ( shouldStartHeaderRefreshing ( ) ) {
25
25
props . onHeaderRefresh &&
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import {IListViewProps} from './ListView.props';
4
4
import { memo } from 'react' ;
5
5
import isEqual from 'react-fast-compare' ;
6
6
7
- const ListView = ( props : IListViewProps ) => {
7
+ const ListView = < ItemT extends { } > ( props : IListViewProps < ItemT > ) => {
8
8
const {
9
9
dataSource,
10
10
refresh,
@@ -15,7 +15,7 @@ const ListView = (props: IListViewProps) => {
15
15
...args
16
16
} = props ;
17
17
const [ refreshState , setRefreshState ] = useState < number > ( RefreshState . Idle ) ;
18
- const [ listData , setListData ] = useState < any [ ] > ( [ ] ) ;
18
+ const [ listData , setListData ] = useState < ItemT [ ] > ( [ ] ) ;
19
19
const [ loadType , setLoadType ] = useState < string > ( ) ;
20
20
21
21
useEffect ( ( ) => {
@@ -68,7 +68,7 @@ const ListView = (props: IListViewProps) => {
68
68
< RefreshListView
69
69
{ ...args }
70
70
data = { listData }
71
- renderItem = { ( { item , index } ) => renderRow ( item , index ) }
71
+ renderItem = { renderRow }
72
72
refreshState = { refreshState }
73
73
onHeaderRefresh = { onHeaderRefresh }
74
74
onFooterRefresh = { onFooterRefresh }
You can’t perform that action at this time.
0 commit comments