From 0c0f8329096a6e9f54fe3a66d00d04224e93b461 Mon Sep 17 00:00:00 2001 From: Steven Date: Wed, 1 May 2024 10:22:24 -0400 Subject: [PATCH] fix(next/image): detect react@19 for `fetchPriority` prop --- packages/next/src/client/image-component.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/next/src/client/image-component.tsx b/packages/next/src/client/image-component.tsx index 80e8aea263e86..a4ef2efe32f8b 100644 --- a/packages/next/src/client/image-component.tsx +++ b/packages/next/src/client/image-component.tsx @@ -8,7 +8,7 @@ import React, { useMemo, useState, forwardRef, - version, + use, } from 'react' import ReactDOM from 'react-dom' import Head from '../shared/lib/head' @@ -168,11 +168,8 @@ function handleLoading( function getDynamicProps( fetchPriority?: string ): Record { - 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 }