@@ -15,9 +15,9 @@ import {
15
15
Pressable ,
16
16
} from 'react-native' ;
17
17
18
- export interface PickerDate {
18
+ export interface PickerData {
19
19
label ?: string ;
20
- render ?: ( key : string , record : PickerDate , index : number ) => React . ReactNode ;
20
+ render ?: ( key : string , record : PickerData , index : number ) => React . ReactNode ;
21
21
[ key : string ] : any ;
22
22
}
23
23
@@ -27,7 +27,7 @@ export interface PickerProps {
27
27
/** 指定需要显示的 key, 默认使用 data 的 label 属性 */
28
28
key ?: string ;
29
29
/** 需要渲染的数据 */
30
- date ?: Array < PickerDate > ;
30
+ data ?: Array < PickerData > ;
31
31
/** item 容器样式 */
32
32
containerStyle ?: {
33
33
/** 激活的容器样式 */
@@ -52,7 +52,7 @@ const Picker = (props: PickerProps) => {
52
52
const {
53
53
lines = 3 ,
54
54
key = 'label' ,
55
- date = new Array < PickerDate > ( ) ,
55
+ data = new Array < PickerData > ( ) ,
56
56
containerStyle = { } ,
57
57
textStyle = { } ,
58
58
value = 0 ,
@@ -70,10 +70,13 @@ const Picker = (props: PickerProps) => {
70
70
useEffect ( ( ) => {
71
71
onChange ?.( current ) ;
72
72
onPressORonScroll . current = 'onScroll' ;
73
+ clearTimeout ( timer . current ! ) ;
74
+ timer . current = undefined ;
75
+ clearTimeout ( onPressTimer . current ! ) ;
73
76
} , [ current ] ) ;
74
77
useEffect ( ( ) => {
75
78
if ( value !== current ) {
76
- let leng = value > date . length - 1 ? date . length - 1 : value ;
79
+ let leng = value > data . length - 1 ? data . length - 1 : value ;
77
80
leng = leng < 0 ? 0 : leng ;
78
81
location ( ( style . containerHeight as number ) * ( leng + 1 ) , leng ) ;
79
82
setCurrent ( leng ) ;
@@ -162,7 +165,7 @@ const Picker = (props: PickerProps) => {
162
165
useNativeDriver : false ,
163
166
} ) }
164
167
>
165
- { date . map ( ( item , index ) => (
168
+ { data . map ( ( item , index ) => (
166
169
< Pressable
167
170
onLayout = { getItemHeight }
168
171
key = { index }
0 commit comments