prismicio / prismic-react

React components and hooks to fetch and present Prismic content
https://prismic.io/docs/technologies/homepage-reactjs
Apache License 2.0
154 stars 40 forks source link

Importing `forwardRef` from `react` is overwritten by @prismicio #134

Closed kropelka77 closed 2 years ago

kropelka77 commented 2 years ago

Versions

Reproduction

Additional Details
Morning, When trying to update `@prismicio/react` to the version 2.1.1, I've noticed that all my currently imported `forwardRefs` from `react` are now pointing to @prismicio implementation (caused by [this change](https://github.com/prismicio/prismic-react/pull/131) I assume). That actually causes an issue with the `displayName` for some files. Nevertheless, even though I could fix the default import with webpack, I don't feel comfortable using the latest update that overwrites it globally. Was that the expected behaviour?

Steps to reproduce

What is expected?

Importing forwardRef from react won't be overwritten by @prismicio in my whole application.

What is actually happening?

All forwardRef imports are coming from @prismicio now.

Screenshot 2022-03-08 at 11 59 18
angeloashmore commented 2 years ago

Hey @kropelka77, thanks for the report. Could you try v2.1.2-alpha.0 and let me know if the issue is fixed and everything work as expected?

Background info: forwardRef support was added to <PrismicLink> in #131 and published in v2.1.1. It uses a TypeScript declaration merging to support generics in prop types, which <PrismicLink> needs. As you found, this causes issues globally in a project. v2.1.2-alpha.0 uses a different strategy to support generics which shouldn't affect projects globally.

angeloashmore commented 2 years ago

Related: #128, #131, #132

kropelka77 commented 2 years ago

Hi @angeloashmore, thank you for your quick reply!

I've checked and v2.1.2-alpha.0 solves the issue for me - it no longer overwrites global forwardRef

angeloashmore commented 2 years ago

Thanks for testing @kropelka77! The fix is published in v2.1.2.