-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[Image] Old images on Movies example app listings #89
[Image] Old images on Movies example app listings #89
Comments
(There's probably a bug here but let me digress a bit with a general problem here. cc @a2) When you have
What's interesting is that on the web, there's actually both behaviors implemented. We haven't made a concrete decision on this one yet and I'm unsure what's the current behavior, but this behavior is worth thinking about. |
Maybe keep a around to make a smooth transition to b, but with a timeout where it transitions to a loading / can't load indicator if it hangs around too long? |
Good idea :) |
The "keep a" experience is probably better at an infrastructural level because you can always get the "blank" way by adding a key to the Image equal to the src. |
@vjeux I've tried using Meanwhile is there workaround we can use to blank the image and force loading the correct one? |
workaround /* @flow */
'use strict';
var React = require('react-native');
var { Image } = React;
// Hack to work around https://github.com/facebook/react-native/issues/89
//
// Render an <Image /> normally.
// When react reuses the component with a new url, force react to render a
// blank image once before rendering the correct url later.
var DelayedImage = React.createClass({
propTypes: Image.propTypes,
getInitialState(): { showImage: boolean } {
return { showImage: true };
},
componentWillReceiveProps: function(nextProps: any) {
if(this.props.source.uri != nextProps.source.uri) {
this.setState({ showImage: false });
setTimeout(() => this.setState({ showImage: true }), 0);
}
},
render: function(): React.Component {
return <Image {...this.props} source={{uri: this.state.showImage ? this.props.source.uri : null}} />
},
});
module.exports = DelayedImage; |
The issue here now is that the images change but the text does not @vjeux - who is the owner of ListView? |
Probably an Image issue; I can't imagine it being specific to ListView. |
This is pretty busted - any updates, @nicklockwood? |
This is a tough one to catch since the results are never consistent. I was still able to reproduce the issue, maybe 1 out of every 4-5 attempts, following @jchris explanation. See demo below for steps... I think the catch here is to make sure each I've noticed some other people having issues with Images rendering properly within ListView and this did the trick.
Not sure if having to add a key a bug or just a requirement to get the images to re-render properly. |
My thought is that a "loadingImage" property? would force the state machine to represent that the image isn't ready. |
Quick observation on this. I've been seeing this bug for sometime now elsewhere. I've tried keying the image, setting it in state, then calling form there. I've dropped debug points and can see the url that was being assigned to the image wasn't what I was seeing. It only happened on one image in my render row though which got me thinking... Through elimination the thing that got it working for me was to remove the |
@christopherdro fixed this in the commit referenced above 😄 |
To reproduce, search for a movie and browse into it, then back out of the movie view to the search, then delete your search terms by holding down the delete key (on your laptop while running in simulator). It seems to be timing dependent but with a few tries I was able to generate the screenshots below.
Maybe this is throttling from the data API? Maybe caching would help?
The text was updated successfully, but these errors were encountered: