next.js: React does not recognize the `fetchPriority` prop on a DOM element.
Link to the code that reproduces this issue
https://github.com/KDederichs/fetch-prio-reproducer
To Reproduce
npm install jest
Current vs. Expected behavior
jest
console.error
Warning: React does not recognize the `fetchPriority` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `fetchpriority` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
at img
at /Users/USER/source_code/fetch-priority-reproducer/node_modules/next/src/client/image-component.tsx:212:5
at /Users/USER/source_code/fetch-priority-reproducer/node_modules/next/src/client/image-component.tsx:372:5
at Home
4 | describe('Tests', () => {
5 | it('it renders without warning', async () => {
> 6 | const {container} = render(
| ^
7 | <Home/>
8 | )
9 | })
at printWarning (node_modules/react-dom/cjs/react-dom.development.js:86:30)
at error (node_modules/react-dom/cjs/react-dom.development.js:60:7)
at validateProperty$1 (node_modules/react-dom/cjs/react-dom.development.js:3757:7)
at warnUnknownProperties (node_modules/react-dom/cjs/react-dom.development.js:3803:21)
at validateProperties$2 (node_modules/react-dom/cjs/react-dom.development.js:3827:3)
at validatePropertiesInDevelopment (node_modules/react-dom/cjs/react-dom.development.js:9541:5)
at setInitialProperties (node_modules/react-dom/cjs/react-dom.development.js:9830:5)
at finalizeInitialChildren (node_modules/react-dom/cjs/react-dom.development.js:10950:3)
at completeWork (node_modules/react-dom/cjs/react-dom.development.js:22232:17)
at completeUnitOfWork (node_modules/react-dom/cjs/react-dom.development.js:26632:16)
at performUnitOfWork (node_modules/react-dom/cjs/react-dom.development.js:26607:5)
at workLoopSync (node_modules/react-dom/cjs/react-dom.development.js:26505:5)
at renderRootSync (node_modules/react-dom/cjs/react-dom.development.js:26473:7)
at performConcurrentWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:25777:74)
at flushActQueue (node_modules/react/cjs/react.development.js:2667:24)
at act (node_modules/react/cjs/react.development.js:2582:11)
at node_modules/@testing-library/react/dist/act-compat.js:47:25
at renderRoot (node_modules/@testing-library/react/dist/pure.js:180:26)
at render (node_modules/@testing-library/react/dist/pure.js:271:10)
at Object.<anonymous> (app/page.spec.tsx:6:35)
Should be no error there
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:41 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8103
Available memory (MB): 16384
Available CPU cores: 8
Binaries:
Node: 20.11.0
npm: 10.2.4
Yarn: 1.22.19
pnpm: 8.15.1
Relevant Packages:
next: 14.3.0-canary.30 // Latest available version is detected (14.3.0-canary.30).
eslint-config-next: N/A
react: 18.3.1
react-dom: 18.3.1
typescript: 5.1.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Image (next/image)
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 48
- Comments: 36 (8 by maintainers)
Commits related to this issue
- downgrades deps to remove annoying warning: https://github.com/vercel/next.js/issues/65161 — committed to tonymtz/tomatoro by tonymtz 3 years ago
- fix(next/image): detect react@19 for `fetchPriority` prop (#65235) In a previous PR, https://github.com/vercel/next.js/pull/47302, detection for `fetchPriority` assumed that https://github.com/face... — committed to vercel/next.js by styfle 3 years ago
- Add new types, fix https://github.com/vercel/next.js/issues/65161 — committed to joonassandell/portfolio by joonassandell 3 years ago
- Downgrade next to v14.2.2 and react to 18.2.0 because of issue https://github.com/vercel/next.js/issues/65161 — committed to a11yphant/a11yphant by thomasdax98 3 years ago
- Downgrade next to v14.2.2 and react to 18.2.0 because of issue https://github.com/vercel/next.js/issues/65161 — committed to a11yphant/a11yphant by thomasdax98 3 years ago
- Convert to TypeScript and add ESLint/Prettier 🤌 (#3) Among the conversion and linting there are additional changes included: * Set proper useEffect deps * Header: Fix initial arrow animation (un... — committed to joonassandell/portfolio by joonassandell 3 years ago
- fix: downgrade react version(https://github.com/vercel/next.js/issues/65161) — committed to RimidalU/my-travels by RimidalU 3 years ago
- Reactのバージョンを18.2.0に変更する Jestを実行すると以下のエラーが出ていた。 Warning: React does not recognize the `fetchPriority` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, sp... — committed to R-Tsukada/art-timeline by R-Tsukada 3 years ago
- fix: react does not recognize the prop to resolve, we pin react to an older version until a fix is out: https://github.com/vercel/next.js/issues/65161 — committed to fvictorio/evm-diff by mds1 2 years ago
- Update nextjs to the latest version (#73) * Update nextjs to the latest version * Fixes after upgrading to nextjs 14 * ci: fix lint check and remove duplicate job * style: ignore package.jso... — committed to mds1/evm-diff by fvictorio 2 years ago
- Downgrade react-dom — committed to aliciatay-zls/banking by aliciatay-zls 2 years ago
- fix: Downgrade react to avoid fetchPriority errors appearing. https://github.com/vercel/next.js/issues/65161 — committed to paddyfed/TalesOfTheBountyHunters by paddyfed 2 years ago
- interim fix for react ‘fetchPriority’ bug see: https://github.com/vercel/next.js/issues/65161 — committed to BuddhaNexus/buddhanexus-frontend-next by aminahbl 2 years ago
- fix(next/image): detect react@19 for `fetchPriority` prop (#65235) In a previous PR, https://github.com/vercel/next.js/pull/47302, detection for `fetchPriority` assumed that https://github.com/face... — committed to vercel/next.js by styfle 3 years ago
- chore: changed react and react-dom versioning to prevent some jest warnings related to next/image https://github.com/vercel/next.js/issues/65161 — committed to J-HernandezM/ananda-web by J-HernandezM 2 years ago
- Update next to fix fetchPriority issue - https://github.com/vercel/next.js/issues/65161 — committed to kadena-community/spirekey by EnoF 2 years ago
- Update next to fix fetchPriority issue - https://github.com/vercel/next.js/issues/65161 — committed to kadena-community/spirekey by EnoF 2 years ago
- feat(nx-dev): update next to fix img fetchpriority error (#26766) ## Current Behavior `fetchpriority` attribute error in Next image loading cmp. <img width="1260" alt="image" src="https://git... — committed to nrwl/nx by juristr 2 years ago
- feat(nx-dev): update next to fix img fetchpriority error (#26766) ## Current Behavior `fetchpriority` attribute error in Next image loading cmp. <img width="1260" alt="image" src="https://github.co... — committed to nrwl/nx by juristr 2 years ago
Same issue here after updating Next from
14.2.2to14.2.3and React from18.2.0to18.3.1.Rolling back Next to
14.2.2did not fix the error, however, keeping Next at14.2.3and rolling just React back to18.2.0fixed the error.@styfle this happens using
next dev, I don’t have any testing libraries in mypackage.json. This seems to be an issue with the latest React update.To be clear, the warning only happens when running
jest, notnext devornext build, correct?This sounds like an issue with
@testing-library/react, notnext.Updated to latest nextjs last night, this started to appear as soon as I imported
Imagefromnext/image.Try
"react": "18.2.0"(without^)."react": "^18.2.0"will install react 18.2.0 or higher.I see. This also seems to impact Pages Router + react@18.3.1
Change
"react": "^18"to"react": "18.2.0"This is fixed in next@14.2.4
same here, fixed after
"react": "18.2.0"and"react-dom": "18.2.0"I hope this mock fixes the issue. Hit thumbs up if it works and thumbs down if it didnt. And let me know the error.
Next.js 13 has no requirement of React 18.3. You can continue to use React 18.2
Note that React 18.2 and 18.3 are identical besides additional warnings.
See https://react.dev/blog/2024/04/25/react-19-upgrade-guide
Seems not to be fixed. Just ran into this problem for the first time today after a fresh install. next@14.2.4 was installed together with react@18.3.1 and jest@29.7.0
This is fixed on the canary channel.
You can try it out today with
npm install next@canary, thanks!Yup. I can now confirm it’s been fixed in 14.2.4
@styfle Thank you it solved my issue, but can you explain to me what was the issue and how this package solved it?
Same error on react 18.3
I am using render() from “@testing-library/react” or “@testing-library/jest-dom” BUT facing the same issue in the following circumstances:
Could you please provide any workaround on this?
So the solution is to upgrade NextJS to latest version?