Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[bug] image isLoaded state was being set to false after it was set to true … #1618

Merged
merged 4 commits into from
Sep 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions packages/venia-ui/lib/components/Image/image.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment, useCallback, useEffect, useState } from 'react';
import React, { Fragment, useCallback, useState } from 'react';
import { func, shape, string } from 'prop-types';

import { mergeClasses } from '../../classify';
Expand Down Expand Up @@ -34,11 +34,6 @@ const Image = props => {
}
}, [onError]);

// On mount, reset loaded to false.
useEffect(() => {
setIsLoaded(false);
}, [src]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not just on the mount but for all cases when src changes. Makes sense because when src changes, image need to be re-fetched. But since we are not handling the fetch part, it is safe to remove this block of code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right! Thank you for that.


// Render a placeholder until the image is loaded.
const placeholderImage = placeholder && !isLoaded && (
<img className={classes.root} src={placeholder} alt={alt} {...rest} />
Expand Down