Skip to content

Commit c4098b8

Browse files
authored
Fix Toast not swipable when rendered with children. (#3023)
* fix pan view not rendered when chidren are passed * changed render condition * removed lodash
1 parent 7c7fde1 commit c4098b8

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/incubator/toast/index.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
ViewStyle,
88
LayoutChangeEvent
99
} from 'react-native';
10-
import _ from 'lodash';
1110
import {Constants, asBaseComponent} from '../../commons/new';
1211
import {useDidUpdate} from '../../hooks';
1312
import {Colors, BorderRadiuses, Spacings, Typography, Shadows} from 'style';
@@ -184,10 +183,6 @@ const Toast = (props: PropsWithChildren<ToastProps>) => {
184183
};
185184

186185
const renderToastContent = () => {
187-
if (!_.isUndefined(children)) {
188-
return children;
189-
}
190-
191186
return (
192187
<PanView
193188
directions={swipeable ? directions.current : []}
@@ -197,11 +192,13 @@ const Toast = (props: PropsWithChildren<ToastProps>) => {
197192
onDismiss={handleDismiss}
198193
threshold={THRESHOLD}
199194
>
200-
<View style={[styles.toastContent, style, backgroundColor ? {backgroundColor} : undefined]}>
201-
{renderIcon()}
202-
{renderMessage()}
203-
{renderRightElement()}
204-
</View>
195+
{children ?? (
196+
<View style={[styles.toastContent, style, backgroundColor ? {backgroundColor} : undefined]}>
197+
{renderIcon()}
198+
{renderMessage()}
199+
{renderRightElement()}
200+
</View>
201+
)}
205202
</PanView>
206203
);
207204
};

0 commit comments

Comments
 (0)