wojtekmaj / react-pdf

Display PDFs in your React app as easily as if they were images.

Home Page:https://projects.wojtekmaj.pl/react-pdf

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Code Sample for React PDF in Vite Not Working Due to Missing React Dependency in Plugin in the vite.config.js

dev-phantom opened this issue · comments

Before you start - checklist

  • I followed instructions in documentation written for my React-PDF version
  • I have checked if this bug is not already reported
  • I have checked if an issue is not listed in Known issues
  • If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo

Description

The code sample provided for React PDF in Vite is currently not functional, as the React dependency is not included in the plugin. This issue is observed in the following location:

Repository: wojtekmaj/react-pdf

Issue Details

When attempting to run the code sample in Vite, it fails to recognize React components due to the missing React dependency. This prevents the proper rendering of the React PDF component.

Possible Solution

Include React as a dependency in the Vite plugin configuration or update the documentation to guide users on how to include React when using the Vite setup.

Thank you for your attention to this matter. Let me know if any further details are required.

Steps to reproduce

  1. Clone the repository: git clone https://github.com/wojtekmaj/react-pdf.git
  2. Navigate to the Vite sample: cd react-pdf/sample/vite
  3. Install dependencies
  4. Run the development server

Expected behavior

The React PDF component should render successfully in the Vite environment.

Actual behavior

The code execution fails, and the console logs indicate that React is not recognized as a dependency.

Additional information

No response

Environment

  • Browser (if applicable):
  • React-PDF version:
  • React version:
  • Webpack version (if applicable):

Odd, works for me without any modifications:

image

Okay closing this in a bit