Skip to content

Commit 0c0f832

Browse files
committed
fix(next/image): detect react@19 for fetchPriority prop
1 parent d62b68f commit 0c0f832

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

packages/next/src/client/image-component.tsx

+3-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import React, {
88
useMemo,
99
useState,
1010
forwardRef,
11-
version,
11+
use,
1212
} from 'react'
1313
import ReactDOM from 'react-dom'
1414
import Head from '../shared/lib/head'
@@ -168,11 +168,8 @@ function handleLoading(
168168
function getDynamicProps(
169169
fetchPriority?: string
170170
): Record<string, string | undefined> {
171-
const [majorStr, minorStr] = version.split('.', 2)
172-
const major = parseInt(majorStr, 10)
173-
const minor = parseInt(minorStr, 10)
174-
if (major > 18 || (major === 18 && minor >= 3)) {
175-
// In React 18.3.0 or newer, we must use camelCase
171+
if (Boolean(use)) {
172+
// In React 19.0.0 or newer, we must use camelCase
176173
// prop to avoid "Warning: Invalid DOM property".
177174
// See https://github.com/facebook/react/pull/25927
178175
return { fetchPriority }

0 commit comments

Comments
 (0)