Skip to content

Commit

Permalink
fix(next/image): detect react@19 for fetchPriority prop
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle committed May 1, 2024
1 parent d62b68f commit 0c0f832
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/next/src/client/image-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, {
useMemo,
useState,
forwardRef,
version,
use,
} from 'react'
import ReactDOM from 'react-dom'
import Head from '../shared/lib/head'
Expand Down Expand Up @@ -168,11 +168,8 @@ function handleLoading(
function getDynamicProps(
fetchPriority?: string
): Record<string, string | undefined> {
const [majorStr, minorStr] = version.split('.', 2)
const major = parseInt(majorStr, 10)
const minor = parseInt(minorStr, 10)
if (major > 18 || (major === 18 && minor >= 3)) {
// In React 18.3.0 or newer, we must use camelCase
if (Boolean(use)) {
// In React 19.0.0 or newer, we must use camelCase
// prop to avoid "Warning: Invalid DOM property".
// See https://github.com/facebook/react/pull/25927
return { fetchPriority }
Expand Down

0 comments on commit 0c0f832

Please sign in to comment.