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

React hooks crashes onLoadEnd #504

Open
dimaportenko opened this issue Jun 26, 2019 · 6 comments
Open

React hooks crashes onLoadEnd #504

dimaportenko opened this issue Jun 26, 2019 · 6 comments
Labels

Comments

@dimaportenko
Copy link

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?

dimaportenko added a commit to dimaportenko/react-native-fast-image that referenced this issue Jun 27, 2019
@dimaportenko
Copy link
Author

I've added pull request which prevents crash in my case
dimaportenko#1

@DylanVann
Copy link
Owner

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

@dimaportenko
Copy link
Author

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

@manithin
Copy link

manithin commented Nov 22, 2019

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

@dimaportenko
Copy link
Author

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

@manithin
Copy link

@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.

leinelissen added a commit to leinelissen/jellyfin-audio-player that referenced this issue Apr 12, 2023
There is some weird behaviour in react-native-fast-image
which causes it to crash whenever the onError or
onLoadEnd prop is set. The issue is documented in
DylanVann/react-native-fast-image#504.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 participants