当首次打开或清除所有数据时,React本机应用程序缓慢加载URL图像

问题描述

我有一个react native应用程序,需要在主页中获取设置,然后根据设置的响应将图像设置为标题。在获取设置之前,我使用本地图像将其显示为横幅。

我的问题是,当我第一次安装应用程序时,获取设置后需要花费一些时间(图像加载需要3-4秒,图像约为300 kbs,它们是jepeg如果有关系)。我尝试在2020-09-06 13:20:41 [scrapy.core.engine] DEBUG: Crawled (404) <GET http://localhost:8050/robots.txt> (referer: None) 2020-09-06 13:21:07 [scrapy.core.engine] DEBUG: Crawled (200) <GET https://www.dermstore.com/all_Brands_100.htm via http://localhost:8050/render.html> (referer: None) 2020-09-06 13:21:07 [scrapy.core.engine] INFO: Closing spider (finished) 2020-09-06 13:21:07 [scrapy.statscollectors] INFO: Dumping Scrapy stats: {'downloader/request_bytes': 898,'downloader/request_count': 3,'downloader/request_method_count/GET': 2,'downloader/request_method_count/POST': 1,'downloader/response_bytes': 311723,'downloader/response_count': 3,'downloader/response_status_count/200': 1,'downloader/response_status_count/404': 1,'downloader/response_status_count/405': 1,'elapsed_time_seconds': 29.315205,'finish_reason': 'finished','finish_time': datetime.datetime(2020,9,6,7,51,179756),'log_count/DEBUG': 1172,'log_count/INFO': 10,'log_count/WARNING': 1,'memusage/max': 54894592,'memusage/startup': 54894592,'response_received_count': 3,'robotstxt/request_count': 2,'robotstxt/response_count': 2,'robotstxt/response_status_count/404': 1,'robotstxt/response_status_count/405': 1,'scheduler/dequeued': 2,'scheduler/dequeued/memory': 2,'scheduler/enqueued': 2,'scheduler/enqueued/memory': 2,'splash/render.html/request_count': 1,'splash/render.html/response_count/200': 1,'start_time': datetime.datetime(2020,50,37,864551)} 2020-09-06 13:21:07 [scrapy.core.engine] INFO: Spider closed (finished) 组件中触发onLoadStartonLoadEnd并记录语句。他们之间有相当长的时间差。它仅在第一次/或从内存中的设置清除所有数据时才发生。下次我启动该应用程序时,图像在ImageonLoadStart之间似乎只有10毫秒的时间,并且图像显示没有任何延迟。 SOme代码段为:

onLoadEnd

在这里,我使用 <imagebackground defaultSource={require('../../assets/homebanner.jpg')} onLoadStart={() => { console.log('loading started'); }} onLoadEnd={() => { console.log('loaded'); this.setState({ bannerImageLoaded: true }) }} source={this.state.settingsLoaded && this.state.bannerImageLoaded ? { uri: this.state.settings.bannerImageUrl } : require('../../assets/homebanner.jpg')} style={{ height: width / 2.5,width: width }} /> 希望它会在uri图像实际加载之前加载,但这似乎没有任何区别。我还尝试了在defaultSource事件中将状态变量bannerImageLoaded设置为true并应用了代码中所示的逻辑。

仍然,它没有任何区别,并且在应用程序的第一次加载时会有一个空白的白框,这使它看起来很糟糕。我该如何处理?

我听说过onLoadEnd,但不想在安装该应用程序后使用它,第二次它没有显示任何麻烦。

请引导我完成这个过程。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...