File tree 7 files changed +44
-23
lines changed
7 files changed +44
-23
lines changed Original file line number Diff line number Diff line change 67
67
"typescript" : " ^4.2.4"
68
68
},
69
69
"peerDependencies" : {
70
+ "@types/react" : " *" ,
71
+ "@types/react-native" : " *" ,
70
72
"react" : " *" ,
71
73
"react-native" : " *" ,
72
74
"react-native-gesture-handler" : " >=1.10.1" ,
73
75
"react-native-reanimated" : " >=2.2.0"
74
76
},
77
+ "peerDependenciesMeta" : {
78
+ "@types/react-native" : {
79
+ "optional" : true
80
+ },
81
+ "@types/react" : {
82
+ "optional" : true
83
+ }
84
+ },
75
85
"react-native-builder-bob" : {
76
86
"source" : " src" ,
77
87
"output" : " lib" ,
Original file line number Diff line number Diff line change @@ -283,9 +283,9 @@ export interface BottomSheetProps
283
283
footerComponent ?: React . FC < BottomSheetFooterProps > ;
284
284
/**
285
285
* A scrollable node or normal view.
286
- * @type React.ReactNode[] | React.ReactNode
286
+ * @type (() => React.ReactElement) | React.ReactNode[] | React.ReactNode
287
287
*/
288
- children : ( ( ) => React . ReactNode ) | React . ReactNode [ ] | React . ReactNode ;
288
+ children : ( ( ) => React . ReactElement ) | React . ReactNode [ ] | React . ReactNode ;
289
289
//#endregion
290
290
291
291
//#region private
Original file line number Diff line number Diff line change 1
- import type { ReactNode } from 'react' ;
1
+ import type { ReactElement , ReactNode } from 'react' ;
2
2
import { ViewStyle } from 'react-native' ;
3
3
import type Animated from 'react-native-reanimated' ;
4
4
@@ -31,7 +31,7 @@ export interface BottomSheetDefaultFooterProps extends BottomSheetFooterProps {
31
31
/**
32
32
* Component to be placed in the footer.
33
33
*
34
- * @type {ReactNode | ReactNode[] }
34
+ * @type {ReactNode | ReactNode[] | (() => ReactElement) }
35
35
*/
36
- children ?: ReactNode | ReactNode [ ] ;
36
+ children ?: ReactNode | ReactNode [ ] | ( ( ) => ReactElement ) ;
37
37
}
Original file line number Diff line number Diff line change @@ -142,30 +142,36 @@ const BottomSheetModalComponent = forwardRef<
142
142
}
143
143
bottomSheetRef . current ?. snapToPosition ( ...args ) ;
144
144
} , [ ] ) ;
145
- const handleExpand = useCallback ( ( ...args ) => {
145
+ const handleExpand = useCallback < BottomSheetMethods [ 'expand' ] > ( ( ...args ) => {
146
146
if ( minimized . current ) {
147
147
return ;
148
148
}
149
149
bottomSheetRef . current ?. expand ( ...args ) ;
150
150
} , [ ] ) ;
151
- const handleCollapse = useCallback ( ( ...args ) => {
152
- if ( minimized . current ) {
153
- return ;
154
- }
155
- bottomSheetRef . current ?. collapse ( ...args ) ;
156
- } , [ ] ) ;
157
- const handleClose = useCallback ( ( ...args ) => {
151
+ const handleCollapse = useCallback < BottomSheetMethods [ 'collapse' ] > (
152
+ ( ...args ) => {
153
+ if ( minimized . current ) {
154
+ return ;
155
+ }
156
+ bottomSheetRef . current ?. collapse ( ...args ) ;
157
+ } ,
158
+ [ ]
159
+ ) ;
160
+ const handleClose = useCallback < BottomSheetMethods [ 'close' ] > ( ( ...args ) => {
158
161
if ( minimized . current ) {
159
162
return ;
160
163
}
161
164
bottomSheetRef . current ?. close ( ...args ) ;
162
165
} , [ ] ) ;
163
- const handleForceClose = useCallback ( ( ...args ) => {
164
- if ( minimized . current ) {
165
- return ;
166
- }
167
- bottomSheetRef . current ?. forceClose ( ...args ) ;
168
- } , [ ] ) ;
166
+ const handleForceClose = useCallback < BottomSheetMethods [ 'forceClose' ] > (
167
+ ( ...args ) => {
168
+ if ( minimized . current ) {
169
+ return ;
170
+ }
171
+ bottomSheetRef . current ?. forceClose ( ...args ) ;
172
+ } ,
173
+ [ ]
174
+ ) ;
169
175
//#endregion
170
176
171
177
//#region bottom sheet modal methods
Original file line number Diff line number Diff line change @@ -44,10 +44,10 @@ export interface BottomSheetModalProps
44
44
45
45
/**
46
46
* A scrollable node or normal view.
47
- * @type React.ReactNode[] | React.ReactNode
47
+ * @type React.ReactNode[] | React.ReactNode | (({ data: any }?) => React.ReactElement)
48
48
*/
49
49
children :
50
- | ( ( { data : any } ?) => React . ReactNode )
50
+ | ( ( { data : any } ?) => React . ReactElement )
51
51
| React . ReactNode [ ]
52
52
| React . ReactNode ;
53
53
}
Original file line number Diff line number Diff line change @@ -39,13 +39,18 @@ export const useBottomSheetDynamicSnapPoints = (
39
39
) ;
40
40
} , [ ] ) ;
41
41
42
+ type HandleContentLayoutProps = {
43
+ nativeEvent : {
44
+ layout : { height : number } ;
45
+ } ;
46
+ } ;
42
47
// callbacks
43
48
const handleContentLayout = useCallback (
44
49
( {
45
50
nativeEvent : {
46
51
layout : { height } ,
47
52
} ,
48
- } ) => {
53
+ } : HandleContentLayoutProps ) => {
49
54
animatedContentHeight . value = height ;
50
55
} ,
51
56
[ animatedContentHeight ]
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ type Callback = (...args: any[]) => any;
8
8
export const useStableCallback = ( callback : Callback ) => {
9
9
const callbackRef = useRef < Callback > ( ) ;
10
10
const memoCallback = useCallback (
11
- ( ...args ) => callbackRef . current && callbackRef . current ( ...args ) ,
11
+ ( ...args : any ) => callbackRef . current && callbackRef . current ( ...args ) ,
12
12
[ ]
13
13
) ;
14
14
useEffect ( ( ) => {
You can’t perform that action at this time.
0 commit comments