Next.js Discord

Discord Forum

Image priority error

Answered
Transvaal lion posted this in #help-forum
Open in Discord
Transvaal lionOP
I am not setting fetchPriority (or fetchpriority), but I am receiving this 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.

I have a Headless WordPress setup in which WP provides the data, and Nextjs renders the data that is sent through GraphQL queries to WP. On the page that is throwing this error, I have a list of posts (<ul>) that will all have a "Featured Image" - though at the moment, only one <li> has an image. The WP image data is sent via props to the FeaturedImage component which then loads the Nextjs Image.

List Item has this:
      {image && (
        <FeaturedImage image={image} className={cx("image")} priority />
      )}


This is FeaturedImage component:
export default function FeaturedImage({
  image,
  width,
  height,
  className,
  priority,
  layout,
  ...props
}) {
  const { sourceUrl, caption } = image;
  const { altText } = image || "alt text unavailable";

  width = width ? width : image?.mediaDetails?.width;
  height = height ? height : image?.mediaDetails?.height;
  layout = layout ?? "responsive";

  return sourceUrl && width && height ? (
    <figure className={className}>
      <Image
        src={sourceUrl}
        alt={altText}
        layout={layout}
        width={width}
        height={height}
        priority={priority}
        {...props}
      />
      {caption && <figcaption>{removeHtmlTags(caption)}</figcaption>}
    </figure>
  ) : null;
}


I understand that priority={true} would prevent lazy loading and prioritize that image. I know it is supposed to be on an "above the fold" image at the top. What is happening here?
Answered by Transvaal lion
I reverted back to where I was after doing all of the above (which includes React v18.3.1), and now the fetchpriority error is gone. Wild.
View full answer

23 Replies

@Transvaal lion I am not setting fetchPriority (or fetchpriority), but I am receiving this 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. I have a Headless WordPress setup in which WP provides the data, and Nextjs renders the data that is sent through GraphQL queries to WP. On the page that is throwing this error, I have a list of posts (<ul>) that will all have a "Featured Image" - though at the moment, only one <li> has an image. The WP image data is sent via props to the FeaturedImage component which then loads the Nextjs Image. List Item has this: {image && ( <FeaturedImage image={image} className={cx("image")} priority /> )} This is FeaturedImage component: export default function FeaturedImage({ image, width, height, className, priority, layout, ...props }) { const { sourceUrl, caption } = image; const { altText } = image || "alt text unavailable"; width = width ? width : image?.mediaDetails?.width; height = height ? height : image?.mediaDetails?.height; layout = layout ?? "responsive"; return sourceUrl && width && height ? ( <figure className={className}> <Image src={sourceUrl} alt={altText} layout={layout} width={width} height={height} priority={priority} {...props} /> {caption && <figcaption>{removeHtmlTags(caption)}</figcaption>} </figure> ) : null; } I understand that priority={true} would prevent lazy loading and prioritize that image. I know it is supposed to be on an "above the fold" image at the top. What is happening here?
This is a React bug, downgrade React to 18.2.0

https://github.com/vercel/next.js/issues/65161
Transvaal lionOP
noted, thank you!
Original message was deleted
Transvaal lionOP
@joulev
I have the latest version of Nextjs and downgraded React and still have this issue after restart. Is there anything else?
Oh I see
Transvaal lionOP
Sorry for ping
Transvaal lionOP
I will delete node modules and package-lock.json real quick to be 100%. But my package-lock says 18.2.0. Thank you for pointing this out. I will check
Delete the cache .next too just in case
Transvaal lionOP
the whole directory?
Yes
Transvaal lionOP
that seems to have broken everything. on screen is:
missing required error components, refreshing...
Uhm, what?
Transvaal lionOP
I deleted .next, package-lock.json, node_modules. then ran npm i and turned on the app. The browser just shows the above text
Not sure why it bombed. going to try to rest
reset*
Transvaal lionOP
i reset to a previous branch and then repeated the process of installing react v18.2.0. I still have the same error.

When I deleted .next directory, the app would not start. I'm not sure how to continue with a full refresh without resetting the cache. is there another way to do that without bombing my page?
Hmm are you running dev mode or prod mode (npm run start)?
Transvaal lionOP
I am running a program called Local that does npm run dev. Any idea why this happens? Local creates an alias for localhost, but both the alias site and the localhost are fully dead after resetting next cache
Not super relevant, but this is what Local looks like. at the bottom is where it shows the npm run dev command
Nope no idea what any of this means. .next is the cache folder and isn’t required to run the app, next dev will automatically create one if it doesn’t find the folder. Never seen the error before.
Transvaal lionOP
shoot, well thanks for pointing out the react issue anyway lol
the app dying may be unrelated at this point
Transvaal lionOP
I reverted back to where I was after doing all of the above (which includes React v18.3.1), and now the fetchpriority error is gone. Wild.
Answer