From 49d318221b7080f4ec47303322fb00cc668654ec Mon Sep 17 00:00:00 2001 From: infeng Date: Wed, 19 Oct 2016 14:46:38 +0800 Subject: [PATCH] fix error when images prop is null --- src/ViewerCore.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ViewerCore.tsx b/src/ViewerCore.tsx index 8b4c575..64f1573 100644 --- a/src/ViewerCore.tsx +++ b/src/ViewerCore.tsx @@ -65,7 +65,11 @@ export default class ViewerCore extends React.Component 0) { + imgSrc = images[activeIndex].src; + } let img = new Image(); img.src = imgSrc; img.onload = () => { @@ -243,8 +247,9 @@ export default class ViewerCore extends React.Component 0) { - activeImg = this.props.images[this.state.activeIndex]; + let images = this.props.images || []; + if (images.length > 0) { + activeImg = images[this.state.activeIndex]; } let zIndex = 1000;