React-native-fast-image: React hooks crashes onLoadEnd

Created on 26 Jun 2019  路  6Comments  路  Source: DylanVann/react-native-fast-image

I'm using FastImage component from react-native-fast-image with React useState in callback.

like this

const Avatar = (props) => {
  const [isImageUploaded, setIsImageUploaded] = useState(false);

  return (
    <View style={sizeStyle}>
      <FastImage
        source={{ uri: profileImg }}
        onLoadEnd={() => {
          setIsImageUploaded(true);
        }}
      />
    </View>
  );
};

Avatar component used inside FlatList and when I'm clearing its data I'm getting crash

enter image description here

Crash disappear without setIsImageUploaded(true); like

<FastImage
  source={{ uri: profileImg }}
  onLoadEnd={() => {
    // setIsImageUploaded(true);
  }}
/>

I'm new to React hooks. Any ideas on how to correctly deal with such cases?

bug

All 6 comments

I've added pull request which prevents crash in my case
https://github.com/troublediehard/react-native-fast-image/pull/1

I'd like to be able to reproduce this issue. It would also be good to know if this affects other callbacks.

I'll try to create a sample project with reproduction.

I'll try to create a sample project with reproduction.

did you get a solution for this? noticed that this happens a lot for me too

@manithin you can use workaround from my pull request https://github.com/DylanVann/react-native-fast-image/pull/506

@manithin you can use workaround from my pull request #506

Thank you! my crash was at setOnFastImageError, however, the same approach you made in the pull request worked there too.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

banphlet picture banphlet  路  3Comments

OmarBasem picture OmarBasem  路  3Comments

guihouchang picture guihouchang  路  4Comments

pehagg picture pehagg  路  3Comments

baba43 picture baba43  路  3Comments