Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reset visible state when src/href changed (#35287)
* fix(#35286): reset visible state when image src changed * fix(#35286): reset visible state when link href changed * test(image): image with new src should be re-lazyloaded * test: apply code suggestions from @styfle's review * test: incorrect condition of image load check
- Loading branch information
Showing
5 changed files
with
139 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
test/integration/image-component/default/pages/lazy-src-change.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react' | ||
import Image from 'next/image' | ||
|
||
const Page = () => { | ||
const [src, setSrc] = React.useState('/test.jpg') | ||
return ( | ||
<div> | ||
<p>Home Page</p> | ||
<div id="spacer" style={{ height: '150vh' }} /> | ||
<Image id="basic-image" src={src} width="400" height="400"></Image> | ||
<button id="button-change-image-src" onClick={() => setSrc('/test.png')}> | ||
Change Image | ||
</button> | ||
</div> | ||
) | ||
} | ||
|
||
export default Page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters