@@ -20,7 +20,9 @@ import { SwipeRow } from "react-native-swipe-list-view";
2020import { IconSlot } from "../../interfaces/Icon" ;
2121import type { Theme } from "../../styles/DefaultTheme" ;
2222import { withTheme } from "../../theming" ;
23- import { SwipeableItemButtonProps } from "./SwipeableItemButton" ;
23+ import SwipeableItemButton , {
24+ SwipeableItemButtonProps ,
25+ } from "./SwipeableItemButton" ;
2426import { SwipeableListContext } from "./SwipeableList" ;
2527import {
2628 RightSwipeProps ,
@@ -87,12 +89,6 @@ const SwipeableItem: React.FC<React.PropsWithChildren<Props>> = ({
8789 disableRightSwipe,
8890 ...rest
8991} ) => {
90- const instanceOfSwipeableItemButtonProps = (
91- object : any
92- ) : object is SwipeableItemButtonProps => {
93- return "title" in object && "revealSwipeDirection" in object ;
94- } ;
95-
9692 const isEmptyObject = ( object : object ) => {
9793 return Object . keys ( object ) . length === 0 ;
9894 } ;
@@ -131,7 +127,7 @@ const SwipeableItem: React.FC<React.PropsWithChildren<Props>> = ({
131127 React . Children . toArray ( children ) . filter (
132128 ( child ) =>
133129 React . isValidElement ( child ) &&
134- instanceOfSwipeableItemButtonProps ( child . props ) &&
130+ child . type === SwipeableItemButton &&
135131 child . props . revealSwipeDirection === "left"
136132 ) as React . ReactElement < SwipeableItemButtonProps > [ ] ,
137133 [ children ]
@@ -142,7 +138,7 @@ const SwipeableItem: React.FC<React.PropsWithChildren<Props>> = ({
142138 React . Children . toArray ( children ) . filter (
143139 ( child ) =>
144140 React . isValidElement ( child ) &&
145- instanceOfSwipeableItemButtonProps ( child . props ) &&
141+ child . type === SwipeableItemButton &&
146142 child . props . revealSwipeDirection === "right"
147143 ) as React . ReactElement < SwipeableItemButtonProps > [ ] ,
148144 [ children ]
@@ -152,8 +148,7 @@ const SwipeableItem: React.FC<React.PropsWithChildren<Props>> = ({
152148 ( ) =>
153149 React . Children . toArray ( children ) . filter (
154150 ( child ) =>
155- React . isValidElement ( child ) &&
156- ! instanceOfSwipeableItemButtonProps ( child . props )
151+ React . isValidElement ( child ) && child . type !== SwipeableItemButton
157152 ) ,
158153 [ children ]
159154 ) ;
0 commit comments