Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: React does not recognize the fetchPriority prop on a DOM element #425

Closed
jlarmstrongiv opened this issue Dec 15, 2023 · 3 comments · Fixed by #644
Closed

Warning: React does not recognize the fetchPriority prop on a DOM element #425

jlarmstrongiv opened this issue Dec 15, 2023 · 3 comments · Fixed by #644

Comments

@jlarmstrongiv
Copy link
Contributor

jlarmstrongiv commented Dec 15, 2023

Describe the bug

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.
    at img
    at Image2 (file:///Users/user/Desktop/projects/project/node_modules/@unpic/react/dist/chunk-W7EQS7E7.mjs:30:42)

To Reproduce

        <UnpicReactImage
          priority
          layout="constrained"
          width={1023}
          height={682}
          src="/static/assets/images/owl.jpg"
          alt="Owl"
          cdn="astro"
        />

Expected behavior
No warnings logged to the console

Desktop (please complete the following information):

  • OS: macOS
  • Browser: Chrome
  • Version: 0.0.23

I suppose the solution is using fetchpriority instead of fetchPriority for now

@jlarmstrongiv
Copy link
Contributor Author

It looks like a fix was merged, but never released facebook/react#25927

It would have to be a manual patch in https://github.com/ascorbic/unpic-img/blob/main/packages/react/src/image.tsx

@acoderacom
Copy link

@jlarmstrongiv can you please guide me how to manually patch the image.tsx

@jlarmstrongiv
Copy link
Contributor Author

@acoderacom something like

    const { fetchPriority, ...camelizedProps } = camelizeProps(transformProps(props));
    return <img fetchpriority={fetchPriority} {...camelizedProps} ref={ref} />;

Though, it will depend on whether the fetchPriority is always set or whether you need to set a default value. You may need to finesse the TypeScript types too, depending on the project settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants