Skip to content

Commit 093d829

Browse files
authored
Incubator.Toast - fix error on Android with no image (#2821)
1 parent c75289b commit 093d829

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

demo/src/screens/incubatorScreens/IncubatorToastScreen.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const TOAST_MESSAGES = {
1919
offline: 'Check Your Internet Connection'
2020
};
2121

22-
// TODO: "ReactImageView: Image source "null" doesn't exist" (Android + preset "none")
2322
class ToastsScreen extends Component {
2423
showToast = false; // keep this state in class instance for immediate response
2524
state = {

src/incubator/toast/index.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import React, {PropsWithChildren, useCallback, useEffect, useMemo, useRef, useState} from 'react';
2-
import {ActivityIndicator, StyleSheet, findNodeHandle, AccessibilityInfo, ViewStyle, LayoutChangeEvent} from 'react-native';
2+
import {
3+
ActivityIndicator,
4+
StyleSheet,
5+
findNodeHandle,
6+
AccessibilityInfo,
7+
ViewStyle,
8+
LayoutChangeEvent
9+
} from 'react-native';
310
import _ from 'lodash';
411
import {Constants, asBaseComponent} from '../../commons/new';
512
import {useDidUpdate} from '../../hooks';
@@ -170,9 +177,11 @@ const Toast = (props: PropsWithChildren<ToastProps>) => {
170177
};
171178

172179
const renderIcon = () => {
173-
return (
174-
<Icon source={toastPreset.icon} resizeMode={'contain'} style={styles.icon} tintColor={toastPreset.iconColor}/>
175-
);
180+
if (toastPreset.icon) {
181+
return (
182+
<Icon source={toastPreset.icon} resizeMode={'contain'} style={styles.icon} tintColor={toastPreset.iconColor}/>
183+
);
184+
}
176185
};
177186

178187
const renderToastContent = () => {

0 commit comments

Comments
 (0)