Skip to content

Commit

Permalink
Fix error with missed selectedImageIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivansultan committed May 8, 2021
1 parent b0fe626 commit 0136412
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/modules/product/Images/Images.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ const Images: React.FC<Props> = (props) => {
);
const [maxLoadedImageIndex, setMaxLoadedImageIndex] = useState(DEFAULT_SELECTED_IMAGE_INDEX);

useEffect(() => {
setSelectedImageIndex(props.selectedImageIndex! || DEFAULT_SELECTED_IMAGE_INDEX);
}, [props.selectedImageIndex]);

const { images, linkProps, dotHeight, containerHeight } = props;
const objectFitSize = props.objectFitSize || DEFAULT_OBJECT_FIT_SIZE;
const Component: any = linkProps ? Link : Div;
if (images.length > 1) {
const selectedImage = images[selectedImageIndex];

useEffect(() => {
setSelectedImageIndex(props.selectedImageIndex!);
}, [props.selectedImageIndex]);

if (images.length > 1) {
let selectedImage = images[selectedImageIndex] || images[props.selectedImageIndex!];
return (
<Aux>
<Component className={styles.Images} {...linkProps}>
Expand Down

0 comments on commit 0136412

Please sign in to comment.