gpt4 book ai didi

javascript - 在 React Native 中需要太多图像的问题

转载 作者:数据小太阳 更新时间:2023-10-29 05:32:30 26 4
gpt4 key购买 nike

我有如下所示的 javascript 文件。它有很多对象(1000+)。由于我们不能在 react-native 中为图像使用动态名称,这是我的解决方法。

"grinning": {
"image": require('./images/1f600.png'),
"shortname": ":grinning:",
}

我在其他一些 React Native 函数中需要此文件并循环显示所有图像。但是在 javascript 文件中需要太多图像时出现内部错误。

{"type":"InternalError","message":"react-packager has encountered an internal error, please check your terminal error output for details"}

终端显示

fs operation timeout

如果我从文件中删除一些条目,这会起作用。

任何建议或更好的方法

最佳答案

known issues Fresco 库负责处理图像和内存限制:

Memory issues with PNG images

React Native Android depends on Frescofor loading and displaying images. Currently we have disableddownsampling because it is experimental, so you may run into memoryissues when loading large PNG images.

因此,如果可以的话,可以尝试压缩您的图像,并且仅在必须渲染时才需要它们。

您还应该检查 bug tracker .这是一个 comparable issue及其修复:

@phones24 wrote:

I optimized my app so it's not cached too many images. I also addedsome more JPEG compression and scale the images down a bit. I alsowrote a path that adds error information to the event.

关于javascript - 在 React Native 中需要太多图像的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38383661/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com