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

view recycling and "prepare for reuse" #84

Closed
farfromrefug opened this issue Nov 30, 2017 · 9 comments
Closed

view recycling and "prepare for reuse" #84

farfromrefug opened this issue Nov 30, 2017 · 9 comments

Comments

@farfromrefug
Copy link

On iOs and android we use "prepare for reuse" to make sure a view is ready to be reused.
The simplest example is Image if there were an image already loaded and you set a new image that wont load (network error or such), you end with a view with the image for another cell.

Is there any way in your lib to set the image to "null" before it is reused?

Thanks

@naqvitalha
Copy link
Collaborator

You can always call setNativeProps directly on the ref of the image in componentWillReceiveProps. That should do.

@farfromrefug
Copy link
Author

@naqvitalha thanks i ll try!

@naqvitalha
Copy link
Collaborator

Close the issue if it worked.

@naqvitalha
Copy link
Collaborator

Inactive for a while. Closing.

@hovox
Copy link

hovox commented May 14, 2018

Hey @naqvitalha .
It's not working for me. It renders old image, then updates with new one.
Here is a componentWillReceiveProps code:

  componentWillReceiveProps() {
    this.img && this.img.setNativeProps({ source: null });

    // console.warn("componentWillReceiveProps img: " + this.img.source);
    // this.img && this.img.setNativeProps({ source: null });
  }

@hovox
Copy link

hovox commented May 14, 2018

I wander if there is an example with images ?

@hovox
Copy link

hovox commented May 14, 2018

@naqvitalha are you using with disableRecycling={true} ?

@farfromrefug
Copy link
Author

@naqvitalha sorry for not responding. Dropped react-native as it was not good enough.
Sorry

@naqvitalha
Copy link
Collaborator

@hovox Try this.img.setNativeProps({ opacity: 0 }). Toggle opacity.
You can check this sample https://snack.expo.io/@naqvitalha/rlv-demo

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

No branches or pull requests

3 participants