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

Cannot read property 'scale' of undefined #23

Closed
MaximRikel opened this issue Aug 7, 2018 · 7 comments
Closed

Cannot read property 'scale' of undefined #23

MaximRikel opened this issue Aug 7, 2018 · 7 comments

Comments

@MaximRikel
Copy link

When I load images after rendering I get "Cannot read property 'scale' of undefined".

@MaximRikel
Copy link
Author

I tested and now I understand the bug.
I can't render ImageView with the initial image being null.
Which means that I need to create some dummy image for it to work.
This will not work:

const DEFAULT_STATE: any = {
item: null,
key: 0,
isImageViewVisible: false
}

@MaximRikel MaximRikel reopened this Aug 7, 2018
@MaximRikel
Copy link
Author

MaximRikel commented Aug 7, 2018

When I replace the 'images' through reducer the ImageView still shows me the default image.

ImageView images={[this.props.item]}
imageIndex={0}
animationType='fade'
isVisible={this.props.isImageViewVisible}

Which means that changing 'images' doesn't work. The component retains the first 'images' given.

@MaximRikel
Copy link
Author

MaximRikel commented Aug 8, 2018

The problem is that you take the 'images' from state instead of props.

Instead of:
render(): Node {
const {animation, renderFooter} = this.props;
const {images, imageIndex, isVisible, scrollEnabled} = this.state;

you need to do this:
render(): Node {
const {images, animation, renderFooter} = this.props;
const {imageIndex, isVisible, scrollEnabled} = this.state;

@antonKalinin
Copy link
Owner

Thanks for issue, let me investigate it. The problem is that in this version there are a lot of logic happens when component receive new images. I think you right and maybe it is not necessary to store images in state, but I need some free time to test it all. Or you can send PR :)

@MaximRikel
Copy link
Author

Sorry, don't have the time.

@vorasudh
Copy link

vorasudh commented Aug 24, 2018

Any progress with this issue?

It seems the takes first image passed to it even when the whole page re-renders. Is there a way to dynamically change the set of images passed to it?

@MaximRikel
Copy link
Author

If you want to fix it yourself, you just need to take the images in render() from props instead of state.

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