Skip to content

Commit 1d5ccff

Browse files
carlrosellpieh
authored andcommitted
fix(gatsby-image): use the cache to tell if the image was already loaded (#11303)
1 parent 2ddb20c commit 1d5ccff

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

packages/gatsby-image/src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,15 @@ class Image extends React.Component {
189189
handleRef(ref) {
190190
if (this.state.IOSupported && ref) {
191191
listenToIntersections(ref, () => {
192+
const imageInCache = inImageCache(this.props)
192193
if (
193194
!this.state.isVisible &&
194195
typeof this.props.onStartLoad === `function`
195196
) {
196-
this.props.onStartLoad({ wasCached: inImageCache(this.props) })
197+
this.props.onStartLoad({ wasCached: imageInCache })
197198
}
198199

199-
this.setState({ isVisible: true, imgLoaded: false })
200+
this.setState({ isVisible: true, imgLoaded: imageInCache })
200201
})
201202
}
202203
}

0 commit comments

Comments
 (0)