开发者

React Native switches local files in Android bundle

开发者 https://www.devze.com 2022-12-07 17:31 出处:网络
I am facing an issue with local images in a React Native app. I have a file where I require all of my app icons, something like this:

I am facing an issue with local images in a React Native app. I have a file where I require all of my app icons, something like this:

export const icons = {
  a: require("a.png"),
  b: require("b.png"),
  c: require("c.png")
};

Then I use these files in the React Native Image component. For instance:

import { icons } from "icons";

<Image
  source={icons.a}
/>

It works fine in dev mode on both iOS and Android. It also works fine on iOS archive in p开发者_JAVA技巧roduction. But in Android production bundle, the icons seem to be randomly switched up. Sometimes icon a is displayed instead of icon b, sometimes it is icon c that is displayed instead of icon a, and so on... Sometimes one of the icon is not even displayed at all.

Can the problem come from requiring all the files in the same file ?

I would appreciate any clue. Thanks a lot.

0

精彩评论

暂无评论...
验证码 换一张
取 消