Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve
next/image
warnings to avoid printing more than once (#34562)
Currently, we print warnings during `next dev` for every render of `next/image`, which can quickly fill the console making it really unfriendly to developers trying to read the logs. This PR changes the behavior so that each unique warning prints at most once. - Related to #33007 - Related to #31340
- Loading branch information
Showing
3 changed files
with
73 additions
and
9 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
23 changes: 23 additions & 0 deletions
23
test/integration/image-component/default/pages/warning-once.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,23 @@ | ||
import React from 'react' | ||
import Image from 'next/image' | ||
|
||
const Page = () => { | ||
const [count, setCount] = React.useState(0) | ||
return ( | ||
<> | ||
<h1>Warning should print at most once</h1> | ||
<Image | ||
id="w" | ||
layout="fixed" | ||
src="/test.png" | ||
width="400" | ||
height="400" | ||
sizes="50vw" | ||
/> | ||
<button onClick={() => setCount(count + 1)}>Count: {count}</button> | ||
<footer>footer here</footer> | ||
</> | ||
) | ||
} | ||
|
||
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