Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error load image in android #1052

Open
quangduxng opened this issue Oct 8, 2024 · 1 comment
Open

Error load image in android #1052

quangduxng opened this issue Oct 8, 2024 · 1 comment
Labels

Comments

@quangduxng
Copy link

Preview:
Untitled
Log:
Untitled
"react-native": "0.70.6",
"react-native-fast-image": "^8.6.3",
Code:

image
Description:
When I download the app for the first time on Android devices with low or average configurations, this issue occurs. Even on the Android Studio emulator, I experience the same problem. It loads for a while but remains the same.""When I download the app for the first time on Android devices with low or average configurations (v9 ,10, 11), this issue occurs. Even on the Android Studio emulator (v12 13 14), I experience the same problem. It loads for a while but remains the same.

Thank you !

@quangduxng quangduxng added the bug label Oct 8, 2024
@vivakimjisu
Copy link

i have same problem
However if I trigger a state update on purpose during the image load

onLoadStart={() => {
        setReRender(true);
}}

it draw image well
here's my component

import {Image, Platform} from 'react-native';
import FastImage, {FastImageProps} from 'react-native-fast-image';
import etcApiController from '../../api/controller/etc';

const CustomFastImage = (props: FastImageProps) => {
  if (!props?.source) {
    return;
  }
  if (Platform.OS === 'ios') {
    return <FastImage {...props} />;
  }
  let source = null;
  if (typeof props.source !== 'string') {
    source = {
      uri: Image.resolveAssetSource(props.source as any).uri,
    };
  } else {
    source = props.source;
  }
  const _props = {
    ...props,
    source,
  };

  const [reRender, setReRender] = useState(false);

  return (
    <FastImage
      onLoadStart={() => {
        setReRender(true);
      }}
      {...(_props as any)}></FastImage>
  );
};

export default CustomFastImage;

I don't want to use this because it seems inefficient, but if forcing a re-render is effective,
Can someone explain why this works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants