11import { type PropsWithChildren , useCallback , useEffect } from 'react' ;
2+ import type { StyleProp , ViewStyle } from 'react-native' ;
23import { View } from 'react-native' ;
34import { GestureDetector } from 'react-native-gesture-handler' ;
45import { runOnUI , useAnimatedRef } from 'react-native-reanimated' ;
@@ -12,6 +13,7 @@ import { error } from '../../utils';
1213
1314/** Props for the Sortable Handle component */
1415export type CustomHandleProps = PropsWithChildren < {
16+ style ?: StyleProp < ViewStyle > ;
1517 /** Controls how the item behaves in the sortable component
1618 * - 'draggable': Item can be dragged and moves with reordering (default)
1719 * - 'non-draggable': Item cannot be dragged but moves with reordering
@@ -21,23 +23,30 @@ export type CustomHandleProps = PropsWithChildren<{
2123 mode ?: 'draggable' | 'fixed-order' | 'non-draggable' ;
2224} > ;
2325
24- export default function CustomHandle ( props : CustomHandleProps ) {
26+ export default function CustomHandle ( {
27+ children,
28+ mode,
29+ style
30+ } : CustomHandleProps ) {
2531 // The item is teleported when it is rendered within the PortalOutlet
2632 // component
2733 const isTeleported = useIsInPortalOutlet ( ) ;
2834
2935 // In case of teleported handle items, we want to render just the
3036 // handle component without any functionality
3137 return isTeleported ? (
32- < View > { props . children } </ View >
38+ < View style = { style } > { children } </ View >
3339 ) : (
34- < CustomHandleComponent { ...props } />
40+ < CustomHandleComponent mode = { mode } style = { style } >
41+ { children }
42+ </ CustomHandleComponent >
3543 ) ;
3644}
3745
3846function CustomHandleComponent ( {
3947 children,
40- mode = 'draggable'
48+ mode = 'draggable' ,
49+ style
4150} : CustomHandleProps ) {
4251 const customHandleContext = useCustomHandleContext ( ) ;
4352 if ( ! customHandleContext ) {
@@ -66,7 +75,11 @@ function CustomHandleComponent({
6675
6776 return (
6877 < GestureDetector gesture = { gesture . enabled ( dragEnabled ) } userSelect = 'none' >
69- < View collapsable = { false } ref = { handleRef } onLayout = { runOnUI ( onLayout ) } >
78+ < View
79+ collapsable = { false }
80+ ref = { handleRef }
81+ style = { style }
82+ onLayout = { runOnUI ( onLayout ) } >
7083 { children }
7184 </ View >
7285 </ GestureDetector >
0 commit comments