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

Duplicate React declaration with Remix #148

Closed vaneenige closed 1 year ago

vaneenige commented 2 years ago

Versions

Steps to reproduce

What is expected?

As Remix is also based on React I expected this to work. We used prismic-reactjs before with Remix without issues.

What is actually happening?

An Identifier 'React' has already been declared error is thrown.

Could-be fix

To try and "fix" the problem I looked in @prismicio/react/dist/index.js and I replaced: import * as React from 'react'; with import React from 'react'; And yes, now everything works as expected, the helpers and slicezone!

Is there a specific reason it should be with the *? Otherwise changing this would be great!

angeloashmore commented 1 year ago

Hi @vaneenige, sorry for the late reply.

I just ran your reproduction and did not get a React error. The component works as it does in, for example, Next.js.

To clarify how I tested this, I followed these steps:

  1. Run npx create-remix@latest.
  2. When asked "What type of app do you want to create?", select: "Just the basics".
  3. When asked "Where do you want to deploy?", select: "Remix App Server".
  4. Install @prismicio/react.
  5. Import and use <SliceZone> with mock data.
  6. Run npm run dev and test the page (tests for development bugs).
  7. Run npm run build && npm run start and test the page (tests for production bugs).

I'm going to close this for now, but please let me know this is an issue you're still experiencing and I will re-open it.

Thanks!