I have a bug on all over my website. "hydration-error-info.js:63 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" it's a next.js 14 website
Assistant
The warning you're encountering is due to React not recognizing the fetchPriority prop on a DOM element. React strips out unknown props on DOM elements to prevent invalid HTML attributes, and fetchPriority (with that exact casing) is not a standard HTML attribute recognized by React.
Why the Warning Occurs:
React's Prop Handling: React recognizes standard HTML attributes and passes them to the DOM elements. Custom or non-standard attributes must be in lowercase to be passed through.
Casing Matters: In HTML, attributes are case-insensitive, but in JSX (and thus React), the casing of props is significant. React expects DOM attributes to be in lowercase.
Unrecognized Props: When you use a prop like fetchPriority (camelCase) on a DOM element (like <img>), React doesn't recognize it as a valid attribute and emits a warning.
Solution:
To fix the warning, you should:
Change the Prop to Lowercase: Replace fetchPriority with fetchpriority (all lowercase) in your JSX code.
Update Your JSX Elements:
jsx
// Before
<img src="your-image.jpg" fetchPriority="high" />
// After
<img src="your-image.jpg" fetchpriority="high" />
Explanation:
By using fetchpriority in lowercase, you're telling React to pass this attribute directly to the underlying DOM element without considering it as a React-specific prop.
This aligns with how custom data attributes (like data-* or aria-*) are handled in React.
Additional Notes:
Next.js Image Component: If you're using Next.js's <Image> component, you should use the priority prop instead of fetchPriority or fetchpriority. The priority prop is specifically designed to prioritize image loading in Next.js.
jsx
import Image from 'next/image';
<Image src="/your-image.jpg" alt="Description" priority />
Compatibility: Ensure that your dependencies (React, Next.js) are updated to versions that support the features you are using.
Change fetchPriority to fetchpriority when using it on DOM elements in React.
If using Next.js's <Image> component, consider using the priority prop.
By making this change, the warning should disappear, and your application will correctly render the fetchpriority attribute in the DOM, helping you manage resource loading priorities without any issues.