I am attempting to display a component from one React application within another using a CDN. While the component works perfectly in its original app, it encounters an error related to the useState hook when imported via CDN. The error is preventing the component from functioning correctly.
Steps to Reproduce:
-
Clone my repository: Cdn-React-Components.
-
The dist folder in the repository contains the build of the other app’s components.
-
To observe the error, run the dist file along with your React app.
-
Start a Python server on port 8000 using the command: python -m http.server 8000.
Desired Behavior:
The component should integrate seamlessly and function correctly within the host React app without encountering errors related to useState.
Problem:
When importing the component via CDN, an error related to use state is thrown, which does not occur when the component is used within its original application.
How can I resolve this issue and successfully integrate the component into the host React app?
3