Closed LudinaReema closed 2 years ago
It should work as you described because the warn image is a local source. Please post how you rendered DropDownAlert component. I suspect it is overwritten, please double check this as well. Thanks
Hi!
Same happens for me. I have run your library as a dependency in my expo app. While running on Android, it does not show the icons in offline mode. In online mode, everything works fine.
Here is the code:
handleConnectivityChange (isConnected) {
if (isConnected) {
this.online = true
this.dropdown.alertWithType('success', 'Success', i18n.t('backonline'))
this.getApiDataOnline()
} else {
this.online = false
this.dropdown.alertWithType('warn', 'Warning', i18n.t('nointernet'))
}
}
The dropdown component was not overwritten.
I can also confirm this. In my React-Native project, I simply show the dropdown if a request is about to be made and the internet is unreachable.
When there is no internet, the icon doesn't show up. When I invert the condition (show the dropdown only if there is internet), the icon shows up as intended.
const netState = await NetInfo.fetch();
if (!netState.isInternetReachable) {
NavigationService.dropDown.alertWithType(
"info",
strings.common.offline_title,
strings.common.offline_message
);
ifNoInternet();
}
If the image is loaded successfully once (for example, if I revert the condition so that the dropdown shows only when there is internet), the image will display even when internet is unavailable. It's probably due to the app caching the image, and retrieving it from the cache.
Although I admit that it's quite strange that RN doesn't want to load a locally stored image if there's no internet.
I use RN 0.60.4 with RNDropdownalert 4.1.1.
This workaround causes a prop types validation, but does allow me to show the error icon when offline (I'm using a data-uri, base64-encoded version of the Material Icons error icon in this example):
<DropdownAlert
defaultContainer={{
padding: 8,
paddingTop: Platform.OS === 'ios' ? 0 : StatusBar.currentHeight,
flexDirection: 'row',
}}
ref={ref => AlertHelper.setDropDown(ref)}
onClose={() => AlertHelper.invokeOnClose()}
// show error image even when offline because of this issue: https://github.com/testshallpass/react-native-dropdownalert/issues/189
errorImageSrc={{
uri:
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjEuNv1OCegAAAfHSURBVHhe7Zzrqt5EFIb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baGFWacRGz9ZaVeDwjWjV5j66GYrvx/EoUR/IiE6Sl6PtBnZC9y4o8+AX4ilCreHEnlETFdeP5WRRD8iIvEZXiHOBufZD93T+WqIxG9Hz2hF3g//3Zk4zKSeLxwzsDiknYit1Ai2JI4vHTT0JxiXEBvMASxZHER/HxsZaTDm1gncfr42MZxdIBPn/Xc3yZE6N9JnU5TJAU+/k7lvkbZWt//o6nD87u83cWrUMiI3OIe9U2H2C0aD2SGHlZcW/iFf+u5IHWTYwL4AVG0LokkWmhlu+wbKXx81ReX6Jo/cS4AF5glMGDsyEH98iNmbMWb6LTtjXP/qsnMEMjObvyVaOtxXGOidAxcRmvH1Gyx+qGBXl89qqIvJO8lrg5dDDeLPH6ESV7rG64AB15VjB32PJJvajwZJhTvXTMeP2Ikj1WNwySt0yegufSibFdyxZKLOu8L3g9f3FLm8PrR5SHHidP/AcF7ImqosnfpQAAAABJRU5ErkJggg==',
}}
/>
It should work as you described because the warn image is a local source. Please post how you rendered DropDownAlert component. I suspect it is overwritten, please double check this as well.
Does this also apply to production builds? This might only happen in development because in that case the images are loaded via the network (the metro bundler).
Does this also apply to production builds?
I can confirm that this only happens in development. I've tested in production, and they work. 👍
There was the same problem on the project. The solution was to update RN 0.61 to version 0.63.3 with RNDropdownalert 4.2.1
Closing as it was confirmed only happens in development so will not fix.
I am trying to display the alert dropdown when there is no internet with the warn default image. The image part won't display. Only the text will display in alert dropdown. Is there a way to display the image in offline mode in iOS and Android?